Class: EneterProtocolFormatter

EneterProtocolFormatter

new EneterProtocolFormatter()

Default Eneter encoding/decoding. It is the default Eneter protocol formatter which can be used in all types of communication.

Encoding of open connection message:
6 bytes - header: ENETER
1 byte - endianess: 10 little endian, 20 big endian
1 byte - string encoding: 10 UTF8, 20 UTF16
1 byte - message type: 10 for open connection
4 bytes - length: 32 bit integer indicating the size (in bytes) of the following string
x bytes - responseReceiverId: client id string

Encoding of close connection message:
The close connection message is not used. The connection is considered closed when the socket is closed.

Encoding of data message:
6 bytes - header: ENETER
1 byte - endianess: 10 little endian, 20 big endian
1 byte - string encoding: 10 UTF8, 20 UTF16
1 byte - message type: 40 for data message
4 bytes - length: 32 bit integer indicating the size (in bytes) of the following string
x bytes - responseReceiverId: client id string
1 byte - message data type: 10 bytes, 20 string
4 bytes - length: 32 bit integer indicating the size (in bytes) of the following data.
y bytes - message data: message data
Source:

Methods

decodeMessage(arrayBufferMessage)

Decodes incoming message.
Parameters:
Name Type Description
arrayBufferMessage ArrayBuffer | String encoded message.
Source:

encodeOpenConnectionMessage(responseReceiverId)

Encodes open connection message.
Parameters:
Name Type Description
responseReceiverId String id of the client opening the connection.
Source:

encodeRequestMessage(responseReceiverId, messageData)

Encodes the request message.
Parameters:
Name Type Description
responseReceiverId String id of the client which sends the message.
messageData String | ArrayBuffer message which shall be sent.
Source: