MXP Class
A class MXP Protocol (Message eXchange Protocol)
Constructor
Item Index
Methods
Attributes
Methods
close
()
protected
Unsubscribe from MXP channels
Returns:
promise which resolves when all channels have been unsubscribed
collectFrames
()
protected
chainable
async
Collect MXP Frames for a particular incoming message / set of messages.
Returns:
promise which resolves a new message consisting of all frames
configureMxpSession
-
sessionKey
-
key
-
body
Store data on a particular MXP session, used for call signalling
Parameters:
-
sessionKey
StringThe session key for which to store session details
-
key
StringThe session key used for encrypting signalling messages
-
body
StringInformation attached with the session, such as proxy URL
constructMXP
-
msgObj
Method to construct MXP Message by padding an incoming MXP Message with necessary parameters
Parameters:
-
msgObj
MXPMessageObjThe MXP Message to pad
Returns:
updated msgObj
destroy
()
protected
Internal function to destroy MXP
Returns:
undefined
getTransport
-
msgObj
Method to retrieve transport by transportId or recipientId's, can be used in a chan with MXPMessageObj as input/output
Parameters:
-
msgObj
MXPMessageObj | ObjectThe object containing the recipientId's in some way, or the transport Id.
Returns:
getTxChannels
-
msgObj
Identify transmit channels for a particular MXPMessageObj
Parameters:
-
msgObj
MXPMessageObjThe message to retrieve Tx channels from
Returns:
msgObj
handleError
-
error
Handle error messages by logging + writing to console if there's an error stack
Parameters:
-
error
ErrorThe error message or object
Returns:
undefined
handleMessage
-
msgObj
Handle decrypted message and pass to the right set of handlers as specified by other parts of the MXP protocol. (i.e., MXPCalling or MXPMessaging)
Parameters:
-
msgObj
MXPMessageObjThe message to handle
Returns:
undefined
identifyEnKey
-
msgObj
Method to identify encryption key. The options are; instance key, session key or transport key.
Parameters:
-
msgObj
MXPMessageObjThe object to identify suitable encryption key for.
Returns:
msgObj
identifyKey
-
assembledMessage
Identify decryption key for a complete MXP message (headers + defragmented content + footers). Analyzes if message was encrypted using a transport key, signal key or instance key.
Parameters:
-
assembledMessage
StringA complete MXP message.
Returns:
promise which resolves into a new with all correct initial data.
init
()
protected
chainable
async
Initializes MXP by setting up necessary PubNub subscriptions
Returns:
promise which resolves when all channels have been subscribed
processUnencryptedForKey
-
sessionKey
Handle previously un-encrypted messages for a particular session key
Parameters:
-
sessionKey
StringThe session key for which to process unencrypted messages
sendMessage
-
message
Send a message over MXP
Parameters:
-
message
MessageMessage to send
Returns:
promise which resolves into the message object
sendMsgAck
-
msgObj
Send a new IM ack over MXP
Parameters:
-
msgObj
MXPMessageObjThe recieved message to acknowledge delivery of
Returns:
undefined
sendMXP
-
msgObj
Send MXP Message as defined by the incoming msgObj {MXPMessageObj}
Parameters:
-
msgObj
MXPMessageObjThe MXP Message to transmitt
Returns:
promise which resolves into the updated message object
signalStatus
()
protected
Check for subscription on Signal
Returns:
boolean, true for subscribed
splitFrames
-
msgObj
Split a full MXP message into many frames. Resulting frames stored in the {MXPMessageObj}
Parameters:
-
msgObj
MXPMessageObjThe message to split into frames
Returns:
msgObj with frames
subscribe
-
channel
Internal function to unsubscribe to channels for a pupnub object
Parameters:
-
channel
StringA channel, or list of channels.
Returns:
promise which resolves null when complete
subscribe
-
channel
Internal function to subscribe to channels for a pupnub object
Parameters:
-
channel
StringA channel, or list of channels.
Returns:
promise which resolves null when complete
subscribe2
-
channel
Internal function to subscribe to special PubNub channels
Parameters:
-
channel
StringA channel, or list of channels.
Returns:
promise which resolves null when complete
transmitFrames
-
msgObj
Transmit MXP Frames stored in a {MXPMessageObj}
Parameters:
-
msgObj
MXPMessageObjthe full MXP object containing all info we need
Returns:
promise which resolves into msgObj
Attributes
Events
_ondisconnectPubNub
protected
Handle disconnects from PubNub, log the event
Event Payload:
-
message
StringReason for discionnect
_onmessagePubNub
protected
Incoming PubNub messages, any channel / origin. Initiatiates the MXP inbound message processing chain.
Event Payload:
-
message
StringThe raw message recieved by PubNub