Your Application might need to send instructions, data to one or more recipients connected in a Session to deploy new features, business workflow. For example, you want to create a Polling mechanism among participants. Portal supports the Custom Signalling method through which you can build such a utility that requires the passing of messages among participants.
Using Custom Signaling Method, you might send messages to all or selected participants in a Room. You can define your custom data structure to pass to meet your business requirement.
Method: sendUserData( message, isBroadcast, RecipientIDs )
Parameters:
@param {JSON}message – JSONObject containing the following custom keys. This object is passed to Recipients in its original form. Portal doesn’t enforce its structure. Be advised to define keys effectively for signaling needs.sender: Sender’s namemessage: Message bodycustom_key: Data
@param {boolean} isBroadcast– Boolean. Use true for Public Broadcast, false for signaling to one or more recipients.@param {Array} RecipientIDs– Array of Client IDs whom you wish to send private messages.
Event Listener:
onReceivedChatDataRoom– Receives signaling in JSONObject. Available up till Android Toolkit v1.5.2. Deprecated on v1.5.3onUserDataReceived– Receives signaling in a JSONObject. Available Android Toolkit v1.5.3 onwards.
// To send message
message = “”; // JSON
var broadcast = true; // Incase of public messaging
Var broadcast = false; // Incase of private messaging.
var array = []; // Incase of public messaging
Var array = [clientiid_1]; // Incase of private messaging.
window.EnxRtc.sendUserData( message,true,array);
// Add Event Listeners
window.EnxRtc.addEventListner("onAcknowledgedSendData", function
(data)
{
console.log(JSON.stringify(data.data));
});
window.EnxRtc.addEventListner("onUserDataReceived",function (data)
console.log(JSON.stringify(data.data));
});
