The EnxRoom.sendUserData() method allows you to send customized data adhering to a structure not bound by EnableX message structure, to one or more users connected in a session. This allows your application to send not just messages but also structured instructions, polls, or any data that requires a customized data structure as per your business requirement.

Class: EnxRoom

Method:  public void sendUserData(JSONObject data, boolean isBroadcast, array RecipientIDs)

Parameters:

  • data – JSON Object containing custom keys. This object is passed to the Recipients without any structure enforcement. Be advised to define keys effectively for signaling needs.
  • isBroadcast – Boolean. Set to true for Public Broadcast and false for signaling to one or more recipients.
  • RecipientIDs – Array of Client IDs of recipients of the message when not broadcasting.

Callback

  • onUserDataReceived – Receives signaling in JSONObject. Available from Android SDK v1.5.3 onwards.

data JSONObject Sample:

// Example: You can put Important Information with custom keys
// You may define the JSONObject as per your business needs

JSONObject data = {
    "sender": "Sender's Name",
    "message": "Message body",
    "custom_key": "Data"
}

To send & receive Custom Signaling

List<String< Recipient_ClientIds;

room.sendMessage(data, true, null); // Signaling to all

// Signaling to one or selected Recipients
room.sendUserData(data, false, Recipient_ClientIds);

// Users receive Signaling Message through Callback
// Available from v1.5.3.
Public void onUserDataReceived(JSONObject jsonobject){
    // Handle JSON Object
} 

Error Codes / Exceptions

CodeDescription
5127Exceeding maximum allowed data transfer rate of 100Kb.