Class: Chat

messages~ Chat


new Chat(connection, attrs)

A DZCOMMUN message. This message contains all persistence logic related to the communications between parties in Drop Zone. Unlike all other messages, It would be expected that these communications would only occur over testnet. Be sure to provide the correct testnet-mode driver to this message's constructor.

There's some esoteric rules about what attributes are valid and when, so unless there's a good reason to be in here, it's probable that the Session object should be performing all management of these messages in your code.

receiverAddr: Chats should be addressed to the person with whom you wish to communicate

NOTE: All attributes that are specified below are also getter properties that can be accessed on this instantiated object.

Parameters:
Name Type Description
connection Driver

blockchain connection

attrs object

Attributes that this Chat contains

Properties
Name Type Description
iv Buffer

An initialization vector for the contents

contents Buffer

The encrypted contents of a message that's been sent.

der Buffer

A Diffie Helmann der to be supplied by a session initiator.

sessionPrivKey Buffer

A Diffie Hellman public key, to be supplied by a recipient of an iniation request, for the purpose of symmetric key exchange.

Extends

Methods


contentsPlain()

Return the decrypted contents of this message.

NOTE: Not all Chat messages have content. Additionally, the symmKey property of this Chat must be set (typically by the Session object) in order for this method to work.

Returns:
Type
String

isAddressedTo(senderAddr, receiverAddr)

Is this message addressed to the specified receiverAddr, from the specified senderAddr

Parameters:
Name Type Description
senderAddr String
receiverAddr String
Returns:
Type
Boolean

isAuth()

Is this message an authentication response to a session initiation request?

Returns:
Type
Boolean

isInit()

Is this message a session initiation request?

Returns:
Type
Boolean

isValid(cb)

Determine whether this message has been properly formatted, and is 'in consensus' with the Drop Zone protocol. Further documentation for this validation result, and it's error messages can be found in the async-validate library.

Parameters:
Name Type Description
cb function

Callback to receive the results of the validity test form: function(err, res)

Inherited From:

save(cb)

Save this message into the blockchain, if it hasn't yet been persisted, and was instantiated without a txid.

NOTE: Validation is not performed as part of this method. It's entirely possible to persist a message into the blockchain that will be ommitted from search/scan results by clients. Validation is performed as part of #find() not #save().

Parameters:
Name Type Description
cb function

Callback which receives the mempool-persisted message in the form: function(err, message)

NOTE: Due to transaction-maleability, the persisted txid may change at the time of actual confirmation. This method merely broadcasts the message into the mempool.

Inherited From:

toTransaction()

Return a hash object representing the serialized components of this transaction suitable for passing onto TxEncode.

Inherited From:
Returns:
Type
object