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

You don’t need to subscribe to your Local Stream as EnableX 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 the Remote Streams in the Room. 

Refer to Handle Active Talkers section for more details.

Class: EnxRoom

Method: public void subscribe(EnxStream remoteStream)

Parameters:

  • remoteStream – The Stream object that needs to be subscribed.

Observer:

  • onStreamAdded – Notification to everyone in the Room when a new Stream is added in the Room thus informing everyone to subscribe to it to receive it.
  • onSubscribedStream – Acknowledgment to the subscriber when they have subscribed to the Stream successfully.
public void onStreamAdded(EnxStream remoteStream) { // There is a new Stream
	room.subscribe(remoteStream); // Subscribe to it.
}

public void onSubscribedStream(EnxStream stream) {
	// You have subscribed to the Stream.
}

Error Codes / Exceptions

CodeDescription
5014Failed to subscribe to the Stream.
5026Stream has already been subscribed.
5027Repeated subscribe() call made while a previous subscription request is in process.
5028Failed to subscribe because subscribe() call is made on the Local Stream.