new Messaging()
Methods
-
accept(message, extHeaders)
-
Accepts the incoming message.
Parameters:
Name Type Description message
MessagingMessage an object that represents the message.
extHeaders
JSON extension headers.
-
getMessage(msgId) → {Object}
-
Gets the pending message from the Session using the given message ID.
Parameters:
Name Type Description msgId
String the message ID.
Returns:
an object that represents the message.
- Type
- Object
-
reject(message, code, reason, extHeaders)
-
Rejects the incoming message.
Parameters:
Name Type Description message
MessagingMessage an object that represents the message.
code
Number the error code used to reject the message; default is 603.
reason
String the reason used to reject the message, default is "Decline".
extHeaders
JSON extension headers.
-
send(message, target, extHeaders) → {String}
-
Sends the text message to the target. When a text message is sent, the SDK will store a {MessagingMessage} object to the {wsc.Session} until a final response for this sent message is received. The application can use getMessage(msgId) to get it out from {wsc.Session}.
Parameters:
Name Type Description message
String the text messge to be sent.
target
String the target of the text message.
extHeaders
JSON extension headers.
Returns:
the sent message ID.
- Type
- String
Events
-
onErrorResponse
-
Callback function that handles message failure response.
Parameters:
Name Type Description message
MessagingMessage an JSON object that represents the message.
code
Number the error code.
reason
String the error reason.
extHeaders
JSON JSON object that represents the extension headers.
-
onNewMessage
-
Callback function for new incoming text message.
Parameters:
Name Type Description message
MessagingMessage an JSON object that represents the message.
extHeaders
JSON JSON object that represents the extension headers.
-
onSuccessResponse
-
Callback function that handles message success response.
Parameters:
Name Type Description message
MessagingMessage an JSON object that represents the message.
extHeaders
JSON JSON object that represents the extension headers.