/ SDKs / Unity
SDKs
Calls SDKs Unity v1
Calls SDKs Unity
Calls SDKs
Unity
Version 1

Enter and exit a room

Copy link

Users can enter a room by using a room ID. When a user enters a room, the user is assigned a unique Participant ID and a participant is created.

To enter a room, you should fetch the room instance from the Sendbird server using the room ID. You can fetch the most up-to-date room instance from the Sendbird server using the SendbirdCall.FetchRoomById() method. Alternatively, you can use the SendbirdCall.GetCachedRoomById() method to retrieve the most recently cached room instance from the Calls SDK.

SendbirdCall.FetchRoomById(ROOM_ID, (room, error) =>
{
    if( error == null ){/* A room with the identifier RoomId is fetched from the Sendbird Server. */}
});

SbRoom room = SendbirdCall.GetCachedRoomById(ROOM_ID);
// Returns the most recently cached room with the room ID from the SDK.
// If there is no such room with the given room ID, null is returned.

Note: A user can enter a room using multiple devices or browser tabs. Entering from each device or browser tab creates a new participant for the user.

After retrieving the room, call the SbRoom.Enter() method to enter the room.

SbRoomEnterParams roomEnterParams = new SbRoomEnterParams();
room.Enter(roomEnterParams, (error) =>
{
    if( error == null ){/* User has successfully entered room. */}
});

To exit a room, use the room.Exit() method.

room.Exit();