57 lines
1.3 KiB
Go
Raw Normal View History

2020-11-01 16:09:48 +01:00
package handler
import (
2020-10-28 19:15:48 +01:00
"demodesk/neko/internal/types"
"demodesk/neko/internal/types/event"
"demodesk/neko/internal/types/message"
)
2020-11-30 18:27:25 +01:00
func (h *MessageHandlerCtx) signalRequest(session types.Session) error {
2020-12-06 18:49:20 +01:00
if !session.CanWatch() {
return nil
}
2021-02-02 19:21:48 +01:00
offer, err := h.webrtc.CreatePeer(session)
if err != nil {
return err
}
2020-11-18 20:30:33 +01:00
return session.Send(
message.SignalProvide{
Event: event.SIGNAL_PROVIDE,
2021-02-02 19:21:48 +01:00
SDP: offer.SDP,
Lite: h.webrtc.ICELite(),
ICE: h.webrtc.ICEServers(),
2020-11-18 20:30:33 +01:00
})
}
2020-11-01 16:09:48 +01:00
func (h *MessageHandlerCtx) signalAnswer(session types.Session, payload *message.SignalAnswer) error {
2021-02-05 18:14:45 +01:00
peer := session.GetWebRTCPeer()
if peer == nil {
h.logger.Debug().Msg("webRTC peer does not exist")
return nil
}
return peer.SignalAnswer(payload.SDP)
}
2021-02-02 20:43:33 +01:00
func (h *MessageHandlerCtx) signalCandidate(session types.Session, payload *message.SignalCandidate) error {
2021-02-05 18:14:45 +01:00
peer := session.GetWebRTCPeer()
if peer == nil {
h.logger.Debug().Msg("webRTC peer does not exist")
return nil
}
return peer.SignalCandidate(*payload.ICECandidateInit)
2021-02-02 20:43:33 +01:00
}
2021-02-05 20:35:30 +01:00
func (h *MessageHandlerCtx) signalVideo(session types.Session, payload *message.SignalVideo) error {
peer := session.GetWebRTCPeer()
if peer == nil {
h.logger.Debug().Msg("webRTC peer does not exist")
return nil
}
return peer.SetVideoID(payload.VideoID)
}