diff --git a/internal/types/event/events.go b/internal/types/event/events.go index 3c4fe972..f2f95380 100644 --- a/internal/types/event/events.go +++ b/internal/types/event/events.go @@ -6,7 +6,7 @@ const ( ) const ( - SIGNAL_REQUEST = "signal/request" // TODO: New. + SIGNAL_REQUEST = "signal/request" SIGNAL_ANSWER = "signal/answer" SIGNAL_PROVIDE = "signal/provide" ) diff --git a/internal/websocket/handler/handler.go b/internal/websocket/handler/handler.go index a1552296..e6b01a49 100644 --- a/internal/websocket/handler/handler.go +++ b/internal/websocket/handler/handler.go @@ -47,6 +47,8 @@ func (h *MessageHandlerCtx) Message(session types.Session, raw []byte) error { var err error switch header.Event { // Signal Events + case event.SIGNAL_REQUEST: + err = h.signalRequest(session) case event.SIGNAL_ANSWER: payload := &message.SignalAnswer{} err = utils.Unmarshal(payload, raw, func() error { diff --git a/internal/websocket/handler/session.go b/internal/websocket/handler/session.go index add341aa..2299120e 100644 --- a/internal/websocket/handler/session.go +++ b/internal/websocket/handler/session.go @@ -7,11 +7,6 @@ import ( ) func (h *MessageHandlerCtx) SessionCreated(session types.Session) error { - // send sdp and id over to client - if err := h.signalProvide(session); err != nil { - return err - } - return nil } diff --git a/internal/websocket/handler/signal.go b/internal/websocket/handler/signal.go index 8acd7741..c6cd9cbd 100644 --- a/internal/websocket/handler/signal.go +++ b/internal/websocket/handler/signal.go @@ -6,7 +6,7 @@ import ( "demodesk/neko/internal/types/message" ) -func (h *MessageHandlerCtx) signalProvide(session types.Session) error { +func (h *MessageHandlerCtx) signalRequest(session types.Session) error { sdp, lite, ice, err := h.webrtc.CreatePeer(session) if err != nil { return err