Skip to main content

Subscription and Unsubscription

For scenarios where you only publish streams without co-hostingNote with others, subscription logic is not required.

tip

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:

    ParameterTypeDescription
    userIdStringRemote host ID
    typeRCRTCMediaTypeMedia type
    tinyboolWhether 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:

    ParameterTypeDescription
    userIdStringRemote host ID
    typeRCRTCMediaTypeMedia type
  • Sample code:

    engine.unsubscribe(userId, RCRTCMediaType.audio_video);