The EnxRoom.sendMessage() method is used to exchange messages between Session participants. It allows you to exchange the following types of messages:

  • Public Messaging: To send messages to all connected users.
  • Private Messaging: To send messages to a specific user.
  • Group Messaging: To send messages to more than one user.

The Messaging feature does not require the sender to publish Local Stream or the receiver to subscribe to Remote Stream.

Class: EnxRoom

Method: public void sendMessage(String message, boolean isBroadcast, array recipientIDs)

Parameters:

  • message – String Message.
  • isBroadcast – Boolean. Set to true for Public Messaging, false for Private Messaging.
  • recipientIDs – Array of Client IDs to receive messages. Applicable for Group and Private Messaging.

Callback:

  • onMessageReceived – Receives message in JSONObject.
String message = "XXX";
List<String> Recipient_ClientIds;

room.sendMessage(message, true, null); // Public Messaging

// Message to one or more selected Recipients
room.sendMessage(MessageOpt, false, Recipient_ClientIds);


// Users Receive Message through Callback. 
// Available from v1.5.3.
Public void onMessageReceived(JSONObject jsonobject){
    String textMessage = jsonObject.getString("msg");
}