Class WireFormat
A protocol that supports all the features of the websocket server. This wireformat knows about acking and the related protocol messages. it uses a json object to transfer, meaning everything has a property name.
- Defined in: wireformat.js
Constructor Attributes | Constructor Name and Description |
---|---|
WireFormat(options)
Creates a new wireformat
|
Method Summary
Method Attributes | Method Name and Description |
---|---|
buildMessage(message)
Builds a message from a string or an object and wraps it in an envelope with meta data for the protocol.
|
|
parseMessage(message)
Parses a message from a string, and detects which type of message it is.
|
|
renderMessage(message)
Render a message to a string for sending over the socket.
|
|
unwrapContent(message)
Unwraps the message from the envelope, this is used before raising the data event on a hookup client.
|
Class Detail
WireFormat(options)
Creates a new wireformat
- Parameters:
- options
Method Detail
-
{Object} buildMessage(message)Builds a message from a string or an object and wraps it in an envelope with meta data for the protocol.
- Parameters:
- {String|Object} message
- The message to send.
- Returns:
- {Object} The message wrapped and ready to send.
-
{Object} parseMessage(message)Parses a message from a string, and detects which type of message it is. It detects if the message is a json string, and then works out if the message is a protocol message or a user message and builds the appropriate data structure. This method is used when a message is received from a remote party. The method is also used when draining a buffer, to read the string entries in the buffer.
- Parameters:
- {String} message
- The string representation of the message to parse.
- Returns:
- {Object} The message object with meta data attached.
-
{String} renderMessage(message)Render a message to a string for sending over the socket.
- Parameters:
- {Object} message
- The message to serialize.
- Returns:
- {String} The string representation of the message to be sent.
-
{String|Object} unwrapContent(message)Unwraps the message from the envelope, this is used before raising the data event on a hookup client.
- Parameters:
- {Object|String} message
- The message for which to get the content.
- Returns:
- {String|Object} The content of the message if any.