Disconnect WebRTC on socket disconnect.

This commit is contained in:
Miroslav Šedivý 2020-12-03 16:45:41 +01:00
parent 7eee6debc7
commit 4670b5187c

View File

@ -113,13 +113,19 @@ func (session *SessionCtx) SetWebSocketPeer(websocket_peer types.WebSocketPeer)
}
func (session *SessionCtx) SetWebSocketConnected(connected bool) {
session.websocket_connected = connected
if connected {
session.websocket_connected = true
session.manager.emmiter.Emit("connected", session)
} else {
session.websocket_connected = false
return
}
session.manager.emmiter.Emit("disconnected", session)
session.websocket_peer = nil
// TODO: Refactor. Only if is WebRTC active.
if err := session.webrtc_peer.Destroy(); err != nil {
session.logger.Warn().Err(err).Msgf("webrtc destroy has failed")
}
}