Log reason for participant close (#776)

* Log reason for participant close

Please suggest better naming for different scenarios if something comes
to mind.

* group service requests

* incorporate feedback

* Change names in tests
This commit is contained in:
Raja Subramanian
2022-06-22 10:32:22 +05:30
committed by GitHub
parent 87c8ec25b9
commit 47b89c155f
9 changed files with 122 additions and 51 deletions
+3 -3
View File
@@ -648,13 +648,13 @@ func (p *ParticipantImpl) Start() {
})
}
func (p *ParticipantImpl) Close(sendLeave bool) error {
func (p *ParticipantImpl) Close(sendLeave bool, reason types.ParticipantCloseReason) error {
if p.isClosed.Swap(true) {
// already closed
return nil
}
p.params.Logger.Infow("closing participant", "sendLeave", sendLeave)
p.params.Logger.Infow("closing participant", "sendLeave", sendLeave, "reason", reason)
// send leave message
if sendLeave {
_ = p.writeMessage(&livekit.SignalResponse{
@@ -1207,7 +1207,7 @@ func (p *ParticipantImpl) handlePrimaryStateChange(state webrtc.PeerConnectionSt
}
if primaryPC.ConnectionState() != webrtc.PeerConnectionStateConnected {
p.params.Logger.Infow("closing disconnected participant")
p.Close(true)
p.Close(true, types.ParticipantCloseReasonPeerConnectionDisconnected)
}
})
p.lock.Unlock()