From 55a2b14aeac51e1633855fa8fbafecca64f0ad8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Sat, 12 Feb 2022 18:46:00 +0100 Subject: [PATCH] webrtc implement signal close. --- internal/session/session.go | 8 +++++++- internal/types/event/events.go | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/session/session.go b/internal/session/session.go index 8e9c4d77..6daaee81 100644 --- a/internal/session/session.go +++ b/internal/session/session.go @@ -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 { diff --git a/internal/types/event/events.go b/internal/types/event/events.go index 74b43f80..b9c37202 100644 --- a/internal/types/event/events.go +++ b/internal/types/event/events.go @@ -15,6 +15,7 @@ const ( SIGNAL_PROVIDE = "signal/provide" SIGNAL_CANDIDATE = "signal/candidate" SIGNAL_VIDEO = "signal/video" + SIGNAL_CLOSE = "signal/close" ) const (