Video Call
  • iOS : Objective-C
  • Android
  • Web
  • Flutter
  • React Native
  • Electron
  • Unity3D
  • Cocos Creator
  • Windows
  • macOS
  • Linux
  • Overview
  • Develop your app
    • Integrate the SDK
    • Implement a basic video call
    • Enhance basic feature
      • Use Tokens for authentication
      • Config your video based on scenes
      • Check the room connection status
      • Set up common video config
      • Set up common audio config
  • Best practices
    • Implement a video call for multiple users
  • Upgrade using advanced features
    • Advanced features
      • Configure the video
        • Watermark the video/Take snapshots
        • Improve your appearance in the video
        • Beautify & Change the voice
        • Configure video codec
        • Output the video in H.265
      • Improve video quality
        • Configure bandwidth management
        • Test network and devices in advance
        • Visualize the sound level
        • Monitor streaming quality
      • Message signaling
        • Convey extra information using SEI
        • Broadcast real-time messages to a room
        • Quotas and limits
      • Play media files
        • Play media files
        • Play sound effects
      • Share the screen
      • Mix the video streams
      • Publish multiple video streams
      • Encrypt the video streams
      • Record video media data
    • Distincitve features
      • Join multiple rooms
      • Customize the video and audio
      • Set the voice hearing range
      • Use the bit mask
      • Play streams via URL
      • Play a transparent gift special effect
  • Upgrade using Add-on
  • Resources & Reference
    • SDK
    • Sample codes
    • API reference
      • Client APIs
      • Server APIs
    • Debugging
      • Error codes
      • Logging/Version number
    • FAQs
    • Key concepts
  • Documentation
  • Video Call
  • Upgrade using advanced features
  • Distincitve features
  • Join multiple rooms

Join multiple rooms

Last updated:2023-08-31 15:50

Introduction

The same user can join multiple rooms at the same time, and publish streams, play streams, send real-time messages and receive message callbacks in multiple rooms at the same time.

  • ZEGO Express SDK supports this function since version 2.9.0.
  • You need to contact ZEGOCLOUD technical support to activate the multiple rooms function.
  • A maximum of 5 rooms can be joined at the same time by default. If you need more, please contact ZEGOCLOUD technical support to provide expansion capabilities.

This feature can be used for various use cases. Here are some examples:

  • Cross-room interactions in live streaming
  • Breakout rooms in virtual classrooms

Prerequisites

Before implementing the function, please make sure:

  • ZEGO Express SDK has been integrated into the project to implement basic real-time audio and video functions. For details, please refer to Quick start .
  • A project has been created in ZEGOCLOUD Console and applied for a valid AppID and AppSign. For details, please refer to Console - Project Information .

Setting up multi-room mode

Before initializing the SDK, call the setRoomMode interface, and set the room mode to multi-room mode through the ZegoRoomMode class, that is, the "mode" value is "ZegoRoomModeMultiRoom".

// Set room mode to multi-room mode
[ZegoExpressEngine setRoomMode:ZegoRoomModeMultiRoom];

Log in to rooms

Enter the roomID and other parameters, and call the loginRoom interface to log in to the room.

In multi-room mode, you can log in to multiple rooms at the same time, and the logged-in user information must be the same.

[[ZegoExpressEngine sharedEngine] loginRoom:@"multi_room_01" user:[ZegoUser userWithUserID:@"multi_room_user"]];

Publish streams

Pass in the streamID, roomID and other parameters, and call the startPublishingStream (with "ZegoPublisherConfig" parameter) interface to publish streams in the specified room.

In multi-room mode, you must use ZegoPublisherConfig to specify the "roomID" associated with the "streamID". After exiting the specified room, the publish streams operation corresponding to the room will be stopped.

ZegoPublisherConfig *config = [[ZegoPublisherConfig alloc] init];
config.roomID = @"multi_room_01";

[[ZegoExpressEngine sharedEngine] startPublishingStream:@"multi_room_publish_01" config:config channel:ZegoPublishChannelMain];

Play streams

Pass in the streamID, roomID and other parameters, and call the startPlayingStream (with "ZegoPlayerConfig" parameter) interface to play streams in the specified room.

In multi-room mode, you must use ZegoPlayerConfig to specify the "roomID" associated with the "streamID". After exiting the specified room, the play streams operation corresponding to the room will be stopped.

ZegoPlayerConfig *config = [[ZegoPlayerConfig alloc] init];
config.roomID = @"multi_room_01";

[[ZegoExpressEngine sharedEngine] startPlayingStream:@"multi_room_player_01" canvas:[ZegoCanvas canvasWithView:self.playView] config:config];

Log out from rooms

Pass in the roomID and call the logoutRoom interface to exit the room.

If you want to log out of all logged-in rooms at once, you can directly call the logoutRoom interface without "roomID".

[[ZegoExpressEngine sharedEngine] logoutRoom:@"multi_room_01"];
Page Directory