Archived
2
0
This repository has been archived on 2024-06-24. You can view files and clone it, but cannot push or open issues or pull requests.
neko-custom/server/internal/websocket/signal.go
Miroslav Šedivý 1ff743c598 rename package.
2021-10-05 22:38:24 +02:00

39 lines
768 B
Go

package websocket
import (
"m1k1o/neko/internal/types"
"m1k1o/neko/internal/types/event"
"m1k1o/neko/internal/types/message"
)
func (h *MessageHandler) signalProvide(id string, session types.Session) error {
sdp, lite, ice, 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,
Lite: lite,
ICE: ice,
}); err != nil {
return err
}
return nil
}
func (h *MessageHandler) signalAnswer(id string, session types.Session, payload *message.SignalAnswer) error {
if err := session.SetName(payload.DisplayName); err != nil {
return err
}
if err := session.SignalAnswer(payload.SDP); err != nil {
return err
}
return nil
}