Skip to content

Commit

Permalink
only create voice handle if requested
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Arregui committed Dec 27, 2023
1 parent f936182 commit ebd5cbe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@ export class LivekitAdapter implements MinimumCommunicationsAdapter {

private disposed = false
private readonly room: Room
private voiceHandler: VoiceHandler
private voiceHandler: VoiceHandler | undefined

constructor(private config: LivekitConfig) {
this.room = new Room()

this.voiceHandler = createLiveKitVoiceHandler(this.room, this.config.globalAudioStream)

this.room
.on(RoomEvent.ParticipantConnected, (_: RemoteParticipant) => {
this.config.logger.log(this.room.name, 'remote participant joined', _.identity)
Expand Down Expand Up @@ -80,6 +78,9 @@ export class LivekitAdapter implements MinimumCommunicationsAdapter {
}

async createVoiceHandler(): Promise<VoiceHandler> {
if (!this.voiceHandler) {
this.voiceHandler = createLiveKitVoiceHandler(this.room, this.config.globalAudioStream)
}
return this.voiceHandler
}

Expand Down
1 change: 1 addition & 0 deletions browser-interface/packages/shared/comms/peers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ function getActiveRooms(): RoomConnection[] {
return rooms
}

;(globalThis as any).getActiveRooms = getActiveRooms
export async function onRoomLeft(oldRoom: RoomConnection) {
const rooms = getActiveRooms()
const newPeerInformationMap = new Map<string, PeerInformation>()
Expand Down

0 comments on commit ebd5cbe

Please sign in to comment.