mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
35 lines
741 B
Go
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
|
|
}
|