new Messaging()
Methods
-
accept(message, extHeaders)
-
Accept the incoming message.
Parameters:
Name Type Description messageMessagingMessage an object that represents the message.
extHeadersJSON extension headers.
-
getMessage(msgId) → {Object}
-
Get the pending message from wsc Session by given message ID.
Parameters:
Name Type Description msgIdString the message ID.
Returns:
an object that represents the message.
- Type
- Object
-
reject(message, code, reason, extHeaders)
-
Reject the incoming message.
Parameters:
Name Type Description messageMessagingMessage an object that represents the message.
codeNumber the error code used to reject the message; default is 603.
reasonString the reason used to reject the message, default is "Decline".
extHeadersJSON extension headers.
-
send(message, target, extHeaders) → {String}
-
Send 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 messageString the text messge to be sent.
targetString the target of the text message.
extHeadersJSON extension headers.
Returns:
the sent message ID.
- Type
- String
Events
-
onErrorResponse
-
Callback function that handles message failure response.
Parameters:
Name Type Description messageMessagingMessage an JSON object that represents the message.
codeNumber the error code.
reasonString the error reason.
extHeadersJSON JSON object that represents the extension headers.
-
onNewMessage
-
Callback function for new incoming text message.
Parameters:
Name Type Description messageMessagingMessage an JSON object that represents the message.
extHeadersJSON JSON object that represents the extension headers.
-
onSuccessResponse
-
Callback function that handles message success response.
Parameters:
Name Type Description messageMessagingMessage an JSON object that represents the message.
extHeadersJSON JSON object that represents the extension headers.