diff --git a/packages/voice/src/app/agent/chat.tsx b/packages/voice/src/app/agent/chat.tsx index 500a3dbd..0b43dd47 100644 --- a/packages/voice/src/app/agent/chat.tsx +++ b/packages/voice/src/app/agent/chat.tsx @@ -659,11 +659,11 @@ export class WebRtcChatManager implements ChatManager { switch (msg.type) { case 'room_info': this.room = new Room(); + this.room.on(RoomEvent.TrackSubscribed, (track) => this.handleTrackSubscribed(track)); + this.room.on(RoomEvent.DataReceived, (payload, participant) => this.handleDataReceived(payload, participant)); await this.room.connect(msg.roomUrl, msg.token); console.log('[chat] connected to room', this.room.name); this.maybePublishLocalAudio(); - this.room.on(RoomEvent.TrackSubscribed, (track) => this.handleTrackSubscribed(track)); - this.room.on(RoomEvent.DataReceived, (payload, participant) => this.handleDataReceived(payload, participant)); break; default: console.warn('unknown message type', msg.type);