mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
session GetWebRTCPeer.
This commit is contained in:
parent
761f6d8a8f
commit
c81bca9b2f
@ -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
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user