neko/server/internal/websocket/identity.go

35 lines
741 B
Go
Raw Normal View History

2020-01-21 03:38:07 +13:00
package websocket
import (
2020-01-25 04:47:37 +13:00
"n.eko.moe/neko/internal/types"
"n.eko.moe/neko/internal/types/event"
"n.eko.moe/neko/internal/types/message"
2020-01-21 03:38:07 +13:00
)
2020-01-25 04:47:37 +13:00
func (h *MessageHandler) identityDetails(id string, session types.Session, payload *message.IdentityDetails) error {
if err := session.SetName(payload.Username); err != nil {
2020-01-21 03:38:07 +13:00
return err
}
return nil
}
2020-01-25 04:47:37 +13:00
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
}