diff --git a/callback.go b/callback.go index d1db4362..07ae9ba8 100644 --- a/callback.go +++ b/callback.go @@ -161,18 +161,17 @@ func GetDisconnectionReason(reason livekit.DisconnectReason) DisconnectionReason } type RoomCallback struct { - OnDisconnected func() - OnDisconnectedWithReason func(reason DisconnectionReason) - OnParticipantConnected func(*RemoteParticipant) - OnParticipantDisconnected func(*RemoteParticipant) - OnParticipantDisconnectedWithReason func(*RemoteParticipant, livekit.DisconnectReason) - OnActiveSpeakersChanged func([]Participant) - OnRoomMetadataChanged func(metadata string) - OnRecordingStatusChanged func(isRecording bool) - OnRoomMoved func(roomName string, token string) - OnReconnecting func() - OnReconnected func() - OnLocalTrackSubscribed func(publication *LocalTrackPublication, lp *LocalParticipant) + OnDisconnected func() + OnDisconnectedWithReason func(reason DisconnectionReason) + OnParticipantConnected func(*RemoteParticipant) + OnParticipantDisconnected func(*RemoteParticipant) + OnActiveSpeakersChanged func([]Participant) + OnRoomMetadataChanged func(metadata string) + OnRecordingStatusChanged func(isRecording bool) + OnRoomMoved func(roomName string, token string) + OnReconnecting func() + OnReconnected func() + OnLocalTrackSubscribed func(publication *LocalTrackPublication, lp *LocalParticipant) // participant events are sent to the room as well ParticipantCallback @@ -184,18 +183,17 @@ func NewRoomCallback() *RoomCallback { return &RoomCallback{ ParticipantCallback: *pc, - OnDisconnected: func() {}, - OnDisconnectedWithReason: func(reason DisconnectionReason) {}, - OnParticipantConnected: func(participant *RemoteParticipant) {}, - OnParticipantDisconnected: func(participant *RemoteParticipant) {}, - OnParticipantDisconnectedWithReason: func(participant *RemoteParticipant, reason livekit.DisconnectReason) {}, - OnActiveSpeakersChanged: func(participants []Participant) {}, - OnRoomMetadataChanged: func(metadata string) {}, - OnRecordingStatusChanged: func(isRecording bool) {}, - OnRoomMoved: func(roomName string, token string) {}, - OnReconnecting: func() {}, - OnReconnected: func() {}, - OnLocalTrackSubscribed: func(publication *LocalTrackPublication, lp *LocalParticipant) {}, + OnDisconnected: func() {}, + OnDisconnectedWithReason: func(reason DisconnectionReason) {}, + OnParticipantConnected: func(participant *RemoteParticipant) {}, + OnParticipantDisconnected: func(participant *RemoteParticipant) {}, + OnActiveSpeakersChanged: func(participants []Participant) {}, + OnRoomMetadataChanged: func(metadata string) {}, + OnRecordingStatusChanged: func(isRecording bool) {}, + OnRoomMoved: func(roomName string, token string) {}, + OnReconnecting: func() {}, + OnReconnected: func() {}, + OnLocalTrackSubscribed: func(publication *LocalTrackPublication, lp *LocalParticipant) {}, } } @@ -217,9 +215,6 @@ func (cb *RoomCallback) Merge(other *RoomCallback) { if other.OnParticipantDisconnected != nil { cb.OnParticipantDisconnected = other.OnParticipantDisconnected } - if other.OnParticipantDisconnectedWithReason != nil { - cb.OnParticipantDisconnectedWithReason = other.OnParticipantDisconnectedWithReason - } if other.OnActiveSpeakersChanged != nil { cb.OnActiveSpeakersChanged = other.OnActiveSpeakersChanged } diff --git a/room.go b/room.go index df4a9672..cc3f364e 100644 --- a/room.go +++ b/room.go @@ -920,8 +920,9 @@ func (r *Room) OnParticipantDisconnect(rp *RemoteParticipant, reason livekit.Dis rp.unpublishAllTracks() r.LocalParticipant.handleParticipantDisconnected(rp.Identity()) + + rp.info.DisconnectReason = reason go r.callback.OnParticipantDisconnected(rp) - go r.callback.OnParticipantDisconnectedWithReason(rp, reason) } func (r *Room) OnSpeakersChanged(speakerUpdates []*livekit.SpeakerInfo) { @@ -1003,7 +1004,7 @@ func (r *Room) OnRoomMoved(moved *livekit.RoomMovedResponse) { r.OnRoomUpdate(moved.Room) for _, rp := range r.GetRemoteParticipants() { - r.OnParticipantDisconnect(rp, livekit.DisconnectReason_ROOM_CLOSED) + r.OnParticipantDisconnect(rp, livekit.DisconnectReason_MIGRATION) } go r.callback.OnRoomMoved(moved.Room.Name, moved.Token)