39 lines
780 B
Go
Raw Normal View History

2020-02-12 23:13:33 +00:00
package websocket
import (
"n.eko.moe/neko/internal/types"
"n.eko.moe/neko/internal/types/event"
"n.eko.moe/neko/internal/types/message"
)
func (h *MessageHandler) signalProvide(id string, session types.Session) error {
2020-04-05 07:07:45 +00:00
sdp, lite, ice, err := h.webrtc.CreatePeer(id, session)
2020-02-12 23:13:33 +00:00
if err != nil {
return err
}
if err := session.Send(message.SignalProvide{
Event: event.SIGNAL_PROVIDE,
ID: id,
SDP: sdp,
2020-04-05 07:07:45 +00:00
Lite: lite,
ICE: ice,
2020-02-12 23:13:33 +00:00
}); err != nil {
return err
}
return nil
}
func (h *MessageHandler) signalAnswer(id string, session types.Session, payload *message.SignalAnswer) error {
2020-04-05 01:33:19 +00:00
if err := session.SetName(payload.DisplayName); err != nil {
2020-02-12 23:13:33 +00:00
return err
}
if err := session.SignalAnswer(payload.SDP); err != nil {
2020-02-12 23:13:33 +00:00
return err
}
return nil
}