webrtc implement signal close.

This commit is contained in:
Miroslav Šedivý 2022-02-12 18:46:00 +01:00
parent d20fa071e7
commit 55a2b14aea
2 changed files with 8 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import (
"github.com/rs/zerolog"
"demodesk/neko/internal/types"
"demodesk/neko/internal/types/event"
)
type SessionCtx struct {
@ -143,10 +144,15 @@ func (session *SessionCtx) SetWebRTCConnected(webrtcPeer types.WebRTCPeer, conne
}
session.webrtcMu.Lock()
if webrtcPeer == session.webrtcPeer {
isCurrentPeer = webrtcPeer == session.webrtcPeer
if isCurrentPeer {
session.webrtcPeer = nil
}
session.webrtcMu.Unlock()
if isCurrentPeer {
session.Send(event.SIGNAL_CLOSE, nil)
}
}
func (session *SessionCtx) GetWebRTCPeer() types.WebRTCPeer {

View File

@ -15,6 +15,7 @@ const (
SIGNAL_PROVIDE = "signal/provide"
SIGNAL_CANDIDATE = "signal/candidate"
SIGNAL_VIDEO = "signal/video"
SIGNAL_CLOSE = "signal/close"
)
const (