Skip to content

Commit 0c0ba02

Browse files
authored
fix(remote_participant): disconnect reason (#805)
* fix(remote_participant): disconnect reason * fix: partially revert #804
1 parent f60f1ff commit 0c0ba02

File tree

2 files changed

+25
-29
lines changed

2 files changed

+25
-29
lines changed

callback.go

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,17 @@ func GetDisconnectionReason(reason livekit.DisconnectReason) DisconnectionReason
161161
}
162162

163163
type RoomCallback struct {
164-
OnDisconnected func()
165-
OnDisconnectedWithReason func(reason DisconnectionReason)
166-
OnParticipantConnected func(*RemoteParticipant)
167-
OnParticipantDisconnected func(*RemoteParticipant)
168-
OnParticipantDisconnectedWithReason func(*RemoteParticipant, livekit.DisconnectReason)
169-
OnActiveSpeakersChanged func([]Participant)
170-
OnRoomMetadataChanged func(metadata string)
171-
OnRecordingStatusChanged func(isRecording bool)
172-
OnRoomMoved func(roomName string, token string)
173-
OnReconnecting func()
174-
OnReconnected func()
175-
OnLocalTrackSubscribed func(publication *LocalTrackPublication, lp *LocalParticipant)
164+
OnDisconnected func()
165+
OnDisconnectedWithReason func(reason DisconnectionReason)
166+
OnParticipantConnected func(*RemoteParticipant)
167+
OnParticipantDisconnected func(*RemoteParticipant)
168+
OnActiveSpeakersChanged func([]Participant)
169+
OnRoomMetadataChanged func(metadata string)
170+
OnRecordingStatusChanged func(isRecording bool)
171+
OnRoomMoved func(roomName string, token string)
172+
OnReconnecting func()
173+
OnReconnected func()
174+
OnLocalTrackSubscribed func(publication *LocalTrackPublication, lp *LocalParticipant)
176175

177176
// participant events are sent to the room as well
178177
ParticipantCallback
@@ -184,18 +183,17 @@ func NewRoomCallback() *RoomCallback {
184183
return &RoomCallback{
185184
ParticipantCallback: *pc,
186185

187-
OnDisconnected: func() {},
188-
OnDisconnectedWithReason: func(reason DisconnectionReason) {},
189-
OnParticipantConnected: func(participant *RemoteParticipant) {},
190-
OnParticipantDisconnected: func(participant *RemoteParticipant) {},
191-
OnParticipantDisconnectedWithReason: func(participant *RemoteParticipant, reason livekit.DisconnectReason) {},
192-
OnActiveSpeakersChanged: func(participants []Participant) {},
193-
OnRoomMetadataChanged: func(metadata string) {},
194-
OnRecordingStatusChanged: func(isRecording bool) {},
195-
OnRoomMoved: func(roomName string, token string) {},
196-
OnReconnecting: func() {},
197-
OnReconnected: func() {},
198-
OnLocalTrackSubscribed: func(publication *LocalTrackPublication, lp *LocalParticipant) {},
186+
OnDisconnected: func() {},
187+
OnDisconnectedWithReason: func(reason DisconnectionReason) {},
188+
OnParticipantConnected: func(participant *RemoteParticipant) {},
189+
OnParticipantDisconnected: func(participant *RemoteParticipant) {},
190+
OnActiveSpeakersChanged: func(participants []Participant) {},
191+
OnRoomMetadataChanged: func(metadata string) {},
192+
OnRecordingStatusChanged: func(isRecording bool) {},
193+
OnRoomMoved: func(roomName string, token string) {},
194+
OnReconnecting: func() {},
195+
OnReconnected: func() {},
196+
OnLocalTrackSubscribed: func(publication *LocalTrackPublication, lp *LocalParticipant) {},
199197
}
200198
}
201199

@@ -217,9 +215,6 @@ func (cb *RoomCallback) Merge(other *RoomCallback) {
217215
if other.OnParticipantDisconnected != nil {
218216
cb.OnParticipantDisconnected = other.OnParticipantDisconnected
219217
}
220-
if other.OnParticipantDisconnectedWithReason != nil {
221-
cb.OnParticipantDisconnectedWithReason = other.OnParticipantDisconnectedWithReason
222-
}
223218
if other.OnActiveSpeakersChanged != nil {
224219
cb.OnActiveSpeakersChanged = other.OnActiveSpeakersChanged
225220
}

room.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -920,8 +920,9 @@ func (r *Room) OnParticipantDisconnect(rp *RemoteParticipant, reason livekit.Dis
920920

921921
rp.unpublishAllTracks()
922922
r.LocalParticipant.handleParticipantDisconnected(rp.Identity())
923+
924+
rp.info.DisconnectReason = reason
923925
go r.callback.OnParticipantDisconnected(rp)
924-
go r.callback.OnParticipantDisconnectedWithReason(rp, reason)
925926
}
926927

927928
func (r *Room) OnSpeakersChanged(speakerUpdates []*livekit.SpeakerInfo) {
@@ -1003,7 +1004,7 @@ func (r *Room) OnRoomMoved(moved *livekit.RoomMovedResponse) {
10031004
r.OnRoomUpdate(moved.Room)
10041005

10051006
for _, rp := range r.GetRemoteParticipants() {
1006-
r.OnParticipantDisconnect(rp, livekit.DisconnectReason_ROOM_CLOSED)
1007+
r.OnParticipantDisconnect(rp, livekit.DisconnectReason_MIGRATION)
10071008
}
10081009

10091010
go r.callback.OnRoomMoved(moved.Room.Name, moved.Token)

0 commit comments

Comments
 (0)