WebRTC + peer closed.

This commit is contained in:
Miroslav Šedivý 2020-12-03 17:03:15 +01:00
parent 4670b5187c
commit c61f5f2835

View File

@ -153,15 +153,18 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session) (string, bool
connection.OnConnectionStateChange(func(state webrtc.PeerConnectionState) {
switch state {
case webrtc.PeerConnectionStateDisconnected:
manager.logger.Info().Str("id", session.ID()).Msg("peer disconnected successfully")
session.SetWebRTCConnected(false)
case webrtc.PeerConnectionStateFailed:
manager.logger.Warn().Str("id", session.ID()).Msg("peer disconnected with error")
session.SetWebRTCConnected(false)
case webrtc.PeerConnectionStateConnected:
manager.logger.Info().Str("id", session.ID()).Msg("peer connected")
session.SetWebRTCConnected(true)
case webrtc.PeerConnectionStateDisconnected:
manager.logger.Info().Str("id", session.ID()).Msg("peer disconnected")
session.SetWebRTCConnected(false)
case webrtc.PeerConnectionStateFailed:
manager.logger.Warn().Str("id", session.ID()).Msg("peer failed")
session.SetWebRTCConnected(false)
case webrtc.PeerConnectionStateClosed:
manager.logger.Warn().Str("id", session.ID()).Msg("peer closed")
session.SetWebRTCConnected(false)
}
})