-
Notifications
You must be signed in to change notification settings - Fork 159
Handle room moved #857
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Handle room moved #857
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| patch type="added" "Handle Room moved event" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -135,6 +135,46 @@ extension Room: SignalClientDelegate { | |
| } | ||
| } | ||
|
|
||
| func signalClient(_: SignalClient, didReceiveRoomMoved response: Livekit_RoomMovedResponse) async { | ||
| log("didReceiveRoomMoved to room: \(response.hasRoom ? response.room.name : "unknown")") | ||
|
|
||
| // Update room info if available | ||
| if response.hasRoom { | ||
| _state.mutate { | ||
| $0.metadata = response.room.metadata | ||
| $0.isRecording = response.room.activeRecording | ||
| $0.numParticipants = Int(response.room.numParticipants) | ||
| $0.numPublishers = Int(response.room.numPublishers) | ||
| } | ||
|
Comment on lines
+143
to
+148
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Other fields like sid / name / maxParticipants / creationTime etc. could be missing ? |
||
| } | ||
|
|
||
| // Disconnect all remote participants | ||
| let participantsToDisconnect = Array(_state.remoteParticipants.values) | ||
| for participant in participantsToDisconnect { | ||
| guard let identity = participant.identity else { continue } | ||
| await participant.unpublishAll(notify: false) | ||
| _state.mutate { $0.remoteParticipants.removeValue(forKey: identity) } | ||
| } | ||
|
|
||
| // Emit room moved event with new room name | ||
| if response.hasRoom { | ||
| delegates.notify(label: { "room.didMoveToRoomNamed \(response.room.name)" }) { | ||
| $0.room?(self, didMoveToRoomNamed: response.room.name) | ||
| } | ||
| } | ||
|
|
||
| // Re-add participants | ||
| var participantsToAdd: [Livekit_ParticipantInfo] = [] | ||
| if response.hasParticipant { | ||
| participantsToAdd.append(response.participant) | ||
| } | ||
| participantsToAdd.append(contentsOf: response.otherParticipants) | ||
|
|
||
| for info in participantsToAdd { | ||
| _state.mutate { $0.updateRemoteParticipant(info: info, room: self) } | ||
| } | ||
|
Comment on lines
+166
to
+175
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It’s not well documented, but response.participant appears to be a LocalParticipant. We should probably call localParticipant.updateInfo instead. (I’m not sure if any of the info actually changes, though.) |
||
| } | ||
|
|
||
| func signalClient(_: SignalClient, didUpdateSpeakers speakers: [Livekit_SpeakerInfo]) async { | ||
| let activeSpeakers = _state.mutate { state -> [Participant] in | ||
| var lastSpeakers = state.activeSpeakers.reduce(into: [Sid: Participant]()) { $0[$1.sid] = $1 } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might need to update the room's token to
Livekit_RoomMovedResponse.token.