send event when participant disconnects
This commit is contained in:
@@ -108,6 +108,8 @@ func (r *Room) RemoveParticipant(id string) {
|
|||||||
if p, ok := r.participants[id]; ok {
|
if p, ok := r.participants[id]; ok {
|
||||||
// also stop connection if needed
|
// also stop connection if needed
|
||||||
p.Close()
|
p.Close()
|
||||||
|
// update clients
|
||||||
|
r.broadcastParticipantState(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(r.participants, id)
|
delete(r.participants, id)
|
||||||
|
|||||||
+2
-4
@@ -85,6 +85,8 @@ func (s *RTCService) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
|
// remove peer from room upon disconnection
|
||||||
|
room.RemoveParticipant(participant.ID())
|
||||||
participant.Close()
|
participant.Close()
|
||||||
log.Infow("WS connection closed")
|
log.Infow("WS connection closed")
|
||||||
}()
|
}()
|
||||||
@@ -108,10 +110,6 @@ func (s *RTCService) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
log.Errorw("could not handle join", "err", err, "participant", participant.ID())
|
log.Errorw("could not handle join", "err", err, "participant", participant.ID())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer func() {
|
|
||||||
// remove peer from room upon disconnection
|
|
||||||
room.RemoveParticipant(participant.ID())
|
|
||||||
}()
|
|
||||||
case *livekit.SignalRequest_Negotiate:
|
case *livekit.SignalRequest_Negotiate:
|
||||||
if participant.State() == livekit.ParticipantInfo_JOINING {
|
if participant.State() == livekit.ParticipantInfo_JOINING {
|
||||||
log.Errorw("cannot negotiate before peer offer", "participant", participant.ID())
|
log.Errorw("cannot negotiate before peer offer", "participant", participant.ID())
|
||||||
|
|||||||
Reference in New Issue
Block a user