2020-02-13 12:13:33 +13: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 {
|
|
|
|
sdp, err := h.webrtc.CreatePeer(id, session)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := session.Send(message.SignalProvide{
|
|
|
|
Event: event.SIGNAL_PROVIDE,
|
|
|
|
ID: id,
|
|
|
|
SDP: sdp,
|
|
|
|
}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *MessageHandler) signalAnswer(id string, session types.Session, payload *message.SignalAnswer) error {
|
|
|
|
if err := session.SetName(payload.Username); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-02-27 01:46:10 +13:00
|
|
|
if err := session.SignalAnswer(payload.SDP); err != nil {
|
2020-02-13 12:13:33 +13:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|