RoomConnectionClient

const roomConnection = client.getRoomConnection()

RoomConnectionClient manages entire room connection. It exposes state subscriptions and provides actions to manage and observe remoteParticipants and in room actions. Room connection s retrieved from the WherebyClient.

Utilities

Method
Returns
Description

getState

RoomConnectionState

Returns the entire room connection state

destroy

void

Destroy the RoomConnectionClient instance.

State Subscriptions

All subscribe methods follow this format:

  • Call signature: subscribeX(callback: (payload: T) => void: () => void

  • Contract: Invokes a callback on initial subscription and whenever the state changes.

  • Returns: an unsubscribe function

Methods

Method
Payload Type
Description

subscribeToChatMessages

messages: ChatMessage[]

Emits chat messages from remote participants

subscribeToCloudRecording

status: { status: "recording" } | undefined

Emits cloud recording status

subscribeToBreakoutConfig

config: BreakoutState

Emits breakout config

subscribeToConnectionStatus

Emits the connection status

subscribeToLiveStream

status: { status: "streaming" } | undefined

Emits streaming status

subscribeToLocalScreenshareStatus

Emits local screenshare status

subscribeToLocalParticipant

participant?: LocalParticipantState

Emits local participant state

subscribeToRemoteParticipants

participants: RemoteParticipantState[]

Emits the remote participant state

subscribeToScreenshares

screenshares: ScreenshareState[]

Emits screenshare state

subscribeToWaitingParticipants

participants: WaitingParticipantState[]

Emits waiting participants

subscribeToSpotlightedParticipants

participants: ClientView[]

Emits spotlighted participants

Actions

Method
Parameters
Returns
Description

joinRoom

void

Join the room specified in WherebyClientOptions

void

Let the room host know that the local participant is waiting and wants to join

setDisplayName

(displayName: string)

void

Change your display name

sendChatMessage

(text: string)

void

Send a chat message to the room

toggleCamera

(enabled?: boolean)

void

Change the state of your camera

toggleMicrophone

(enabled?: boolean)

void

Change the state of your microphone

toggleLowDataMode

(enabled?: boolean)

void

Change the state of low data mode

toggleRaiseHand

(enabled?: boolean)

void

Toggle raising and lowering your hand in the meeting. Any host in the meeting can acknowledge your request with the askToSpeak host action.

acceptWaitingParticipant

(participantId: string) => void

void

Accept waiting participant

rejectWaitingParticipant

void

Reject waiting participant

startScreenshare

void

Start screen share

stopScreenshare

void

Stop screen share

leaveRoom

void

Leave the room

joinBreakoutGroup

(group: string)

void

Join a breakout group.

joinBreakoutMainRoom

void

Join the main room in a breakout session.

Events

RoomConnectionClient extends EventEmitter . You can listen to lifecycle and state change events directly:

import { REMOTE_PARTICIPANTS_CHANGED } from "@whereby.com/core";

const roomConnection = client.getRoomConnection();

function logChatMessage(message: ChatMessage) {
    console.log("New chat message received", message);
}

roomConnection.on(REMOTE_PARTICIPANTS_CHANGED, logChatMessage);

RoomConnectionEvents

Event (constant)
Event name (string)
Payload
Emitted when

BREAKOUT_CONFIG_CHANGED

breakout:config-changed

Breakout config changes

CHAT_NEW_MESSAGE

chat:new-message

messages: ChatMessage[]

A new chat message is receieved

CLOUD_RECORDING_STATUS_CHANGED

cloud-recording:status-changed

status: { status: "recording" } | undefined

Cloud recording is started or stopped

CONNECTION_STATUS_CHANGED

connection:status-changed

There's a change to connection status

LOCAL_PARTICIPANT_CHANGED

local-participant:changed

participant?: LocalParticipantState

There's a change to the local participant state

LOCAL_SCREENSHARE_STATUS_CHANGED

local-screenshare:status-changed

Local screenshare is started or stopped

REMOTE_PARTICIPANTS_CHANGED

remote-participants:changed

participants: RemoteParticipantState[]

There's a change to the remote participant state

SCREENSHARE_STARTED

screenshare:started

screenshares: ScreenshareState[]

Remote screenshare is started or stopped

ROOM_JOINED

room:joined

A client joins the room

ROOM_JOINED_ERROR

room:joined:error

error: RoomJoinedErrors | string

A client leaves the room

WAITING_PARTICIPANT_JOINED

waiting-participant:joined

A client joins the waiting room

WAITING_PARTICIPANT_LEFT

waiting-participant:left

participantId: string

A client leaves the waiting room

SPOTLIGHT_PARTICIPANT_ADDED

spotlight:participant-added

particpant: ClientView

A client is spotlighted

SPOTLIGHT_PARTICIPANT_REMOVED

spotlight:participant-removed

participantId: string

A client is removed from the spotlight

STREAMING_STARTED

streaming:started

streaming: LiveStreamState

Streaming is started

STREAMING_STOPPED

streaming:stopped

void

Streaming is stopped

Last updated

Was this helpful?