diff --git a/internal/session/session.go b/internal/session/session.go index 1e607a1a..8b667a15 100644 --- a/internal/session/session.go +++ b/internal/session/session.go @@ -2,7 +2,6 @@ package session import ( "github.com/rs/zerolog" - "github.com/pion/webrtc/v3" "demodesk/neko/internal/types" "demodesk/neko/internal/types/event" @@ -189,18 +188,6 @@ func (session *SessionCtx) SetWebRTCConnected(connected bool) { } } -func (session *SessionCtx) SignalAnswer(sdp string) error { - if session.webrtc_peer == nil { - return nil - } - - return session.webrtc_peer.SignalAnswer(sdp) -} - -func (session *SessionCtx) SignalCandidate(candidate webrtc.ICECandidateInit) error { - if session.webrtc_peer == nil { - return nil - } - - return session.webrtc_peer.SignalCandidate(candidate) +func (session *SessionCtx) GetWebRTCPeer() types.WebRTCPeer { + return session.webrtc_peer } diff --git a/internal/types/session.go b/internal/types/session.go index 9c74d905..92a2feaa 100644 --- a/internal/types/session.go +++ b/internal/types/session.go @@ -1,10 +1,6 @@ package types -import ( - "net/http" - - "github.com/pion/webrtc/v3" -) +import "net/http" type MemberProfile struct { Secret string `json:"secret,omitempty"` @@ -61,8 +57,7 @@ type Session interface { // webrtc SetWebRTCPeer(webrtc_peer WebRTCPeer) SetWebRTCConnected(connected bool) - SignalAnswer(sdp string) error - SignalCandidate(candidate webrtc.ICECandidateInit) error + GetWebRTCPeer() WebRTCPeer } type SessionManager interface { diff --git a/internal/websocket/handler/signal.go b/internal/websocket/handler/signal.go index d7cfc62d..b85f78e8 100644 --- a/internal/websocket/handler/signal.go +++ b/internal/websocket/handler/signal.go @@ -26,9 +26,21 @@ func (h *MessageHandlerCtx) signalRequest(session types.Session) error { } func (h *MessageHandlerCtx) signalAnswer(session types.Session, payload *message.SignalAnswer) error { - return session.SignalAnswer(payload.SDP) + peer := session.GetWebRTCPeer() + if peer == nil { + h.logger.Debug().Msg("webRTC peer does not exist") + return nil + } + + return peer.SignalAnswer(payload.SDP) } func (h *MessageHandlerCtx) signalCandidate(session types.Session, payload *message.SignalCandidate) error { - return session.SignalCandidate(*payload.ICECandidateInit) + peer := session.GetWebRTCPeer() + if peer == nil { + h.logger.Debug().Msg("webRTC peer does not exist") + return nil + } + + return peer.SignalCandidate(*payload.ICECandidateInit) }