The EnxRoom.subscribe() method is used to receive the media stream of other users connected to the Room. This method must be called for each participant’s media stream individually to receive it.  

After being connected to the Room, the client application can access the list of streams in the Room through the Room Meta Information ie. { streams: [] } and call the EnxRoom.subscribe() on each stream. The user can subscribe to a maximum of 12 active talkers in the room, one stream for screen sharing (StreamID# 11), and one stream for canvas streaming (StreamID# 21) if the client application supports screen sharing or canvas streaming. This means that the user can see a maximum 12 participants on the UI and these participants keep getting updated as per their activity in the Room. This is further explained in the Handle Active Talkers section.

The user does not need to subscribe to their local stream and EnableX also facilitates the publisher to receive their own screen sharing and canvas streaming without explicitly subscribing to it. In short, a user must only subscribe to remote streams in the room. 

Method: EnxRoom.subscribe(RemoteStream, SubsOptions, Callback)

Parameters:

  • RemoteStream – The Stream object that needs to be subscribed/received.
  • SubsOptions – Lists configurable stream subscription options as given below: 
    • audio – Boolean. Set to true to subscribe to Audio of the Stream.
    • video – Boolean. Set to true to subscribe to Video of the Stream.
    • data – Boolean. Set to true to subscribe to Data of the Stream.

Event Notification:

  • stream-subscribed – Acknowledgment to the subscriber when they have subscribed to the Stream successfully.
var subsOptiions = {
    audio: true,
    video: true,
    data: true
};

// Subscribe to all Streams in Room Metaa
for (var i = 0; i < success.streams.length; i++) {
    room.subscribe(success.streams[i],  subsOptiions  );  
}  

room.addEventListener("stream-subscribed", function(event) {
    // Stream subscribed
});