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: -(void)sendUserData:(NSDictionary *)Message isBroadCast:(BOOL)broadcast recipientIDs:(NSArray *)clientIds;

Parameters:

  • Message – Dictionary containing custom keys. This object is passed to the Recipients without any structure enforcement. Be advised to define keys effectively for signaling needs.
  • isBroadCast – BOOL. 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.

Delegate Method

  • - room:didUserDataReceived: – Receives signaling in JSONObject. Available from iOS SDk v1.5.3 onwards.

Message Dictionary Sample:

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

NSDictionary* message = @{
    "sender": "Sender's Name",
    "message": "Message body",
    "custom_key": "Data"
}

To send & receive Custom Signaling

NSArray *clientArray = [NSArray arrayWithObjects:@"xxx",@"xxx", nil]

// Signaling to one or selected Recipients
[room sendUserData: message broadCast:false recipientIDs:clientArray]; 

// Users receive Signal through Callback 
// Available till v1.5.2. Deprecated in v1.5.3
- (void)room:(EnxRoom *)room didReceiveChatDataAtRoom:(NSArray *)data {
    // data contains incoming message
}

// Users receive Signal through Callback 
// Available from v1.5.3.
- (void)room:(EnxRoom *)room didUserDataReceived:(NSArray *)data {
    // data contains incoming message
}

Error Codes / Exceptions

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