Message

Message

(private) new Message()

Source:

Message class.

Extends

  • EventEmitterExtra

Members

(static, readonly) ErrorCode :string

Source:
Properties:
Name Type Description
INVALID_JSON string

mInvalidJson

MISSING_ID string

mMissingId

ALREADY_RESPONDED string

mAlreadyResponded

Type:
  • string

(static, readonly) Name :string

Source:
Properties:
Name Type Description
RESPONSE string

_r

HANDSHAKE string

_h

PING string

_p

These message names are reserved for internal usage. We recommend to not use any message name starts with _ (underscore).

Type:
  • string

Methods

reject(erropt)

Source:

Rejects the message, with sending error response back to the source.

This method can throw:

  • Message.ErrorCode.MISSING_ID: Message source is not expecting a response.
  • Message.ErrorCode.ALREADY_RESPONDED: This message is already responded.
  • Message.ErrorCode.INVALID_JSON: Could not stringify payload. Probably circular json.
Parameters:
Name Type Attributes Description
err any <optional>

resolve(payloadopt)

Source:

Resolves the message with sending a response back. If the source does not expecting a response, you don't need to call these methods.

This method can throw:

  • Message.ErrorCode.MISSING_ID: Message source is not expecting a response.
  • Message.ErrorCode.ALREADY_RESPONDED: This message is already responded.
  • Message.ErrorCode.INVALID_JSON: Could not stringify payload. Probably circular json.
Parameters:
Name Type Attributes Description
payload any <optional>