Video Call
  • iOS
  • Android : Java
  • Web
  • Flutter
  • React Native
  • Electron
  • Unity3D
  • Cocos Creator
  • Windows
  • macOS
  • Linux
  • Overview
  • Develop your app
    • Quick start
    • 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
    • Implement call invitation
    • Implement a live audio room
  • 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
      • Transfer traffic via the cloud proxy server
      • Use the bit mask
      • Play streams via URL
      • Play a transparent gift special effect
      • AI Voice Changer
      • In-game voice chat
  • 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 you begin, make sure you complete the following:

  • Create a project in ZEGOCLOUD Admin Console and get the AppID and AppSign of your project.

  • Refer to the Quick Start doc to complete the SDK integration and basic function implementation.

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 "MULTI_ROOM".

// Set room mode to multi-room mode
ZegoExpressEngine.setRoomMode(ZegoRoomMode.MULTI_ROOM);

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.

ZegoUser user = new ZegoUser("user1");
engine.loginRoom("room1", 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 = new ZegoPublisherConfig();
config.roomID = "room1";

engine.startPublishingStream("stream1", config, ZegoPublishChannel.MAIN);

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 = new ZegoPlayerConfig();
config.roomID = "room1";

engine.startPlayingStream("stream1", new ZegoCanvas(play_view), 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".

engine.logoutRoom("room1");
Page Directory