neko/server/internal/websocket/identity.go
2020-01-24 15:47:37 +00:00

35 lines
741 B
Go

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) identityDetails(id string, session types.Session, payload *message.IdentityDetails) error {
if err := session.SetName(payload.Username); err != nil {
return err
}
return nil
}
func (h *MessageHandler) createPeer(id string, session types.Session, payload *message.Signal) error {
sdp, peer, err := h.webrtc.CreatePeer(id, payload.SDP)
if err != nil {
return err
}
if err := session.SetPeer(peer); err != nil {
return err
}
if err := session.Send(message.Signal{
Event: event.SIGNAL_ANSWER,
SDP: sdp,
}); err != nil {
return err
}
return nil
}