Subscription and Unsubscription
For scenarios where you only publish streams without co-hosting
Note with others, subscription logic is not required.
Co-hosting
refers to a live streaming scenario where the host invites audience members to join as co-hosts. After switching roles, co-hosts need to subscribe to each other's streams for mutual visibility.
Subscribe to Resources
When multiple hosts are present in a live room, they need to subscribe to each other's streams to see and hear one another. Call the subscribe
method in RCRTCEngine
to subscribe to host resources.
-
Parameters:
Parameter Type Description userId String Remote host ID type RCRTCMediaType Media type tiny bool Whether to subscribe to the low-resolution stream Optional -
Sample code:
engine.subscribe(userId, RCRTCMediaType.audio_video);
Unsubscribe from Resources
To unsubscribe, call the unsubscribe
method in RCRTCEngine
. This method is typically paired with subscribe
, but if a user intends to leave the room, manually unsubscribing is unnecessary—the SDK handles this automatically during room exit.
-
Parameters:
Parameter Type Description userId String Remote host ID type RCRTCMediaType Media type -
Sample code:
engine.unsubscribe(userId, RCRTCMediaType.audio_video);