From 753fb01955472335836ee92540f84ce502bbd7a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Mon, 30 Nov 2020 18:52:16 +0100 Subject: [PATCH] removed OnCreated event. --- internal/session/manager.go | 10 ++-------- internal/session/session.go | 1 - internal/types/session.go | 1 - internal/websocket/handler/session.go | 4 ---- internal/websocket/manager.go | 8 -------- 5 files changed, 2 insertions(+), 22 deletions(-) diff --git a/internal/session/manager.go b/internal/session/manager.go index be48a6cf..7803c144 100644 --- a/internal/session/manager.go +++ b/internal/session/manager.go @@ -220,8 +220,8 @@ func (manager *SessionManagerCtx) OnHostCleared(listener func(session types.Sess }) } -func (manager *SessionManagerCtx) OnCreated(listener func(session types.Session)) { - manager.emmiter.On("created", func(payload ...interface{}) { +func (manager *SessionManagerCtx) OnConnected(listener func(session types.Session)) { + manager.emmiter.On("connected", func(payload ...interface{}) { // Start streaming, when first joins if !manager.capture.Streaming() { manager.capture.StartStream() @@ -231,12 +231,6 @@ func (manager *SessionManagerCtx) OnCreated(listener func(session types.Session) }) } -func (manager *SessionManagerCtx) OnConnected(listener func(session types.Session)) { - manager.emmiter.On("connected", func(payload ...interface{}) { - listener(payload[0].(*SessionCtx)) - }) -} - func (manager *SessionManagerCtx) OnDisconnected(listener func(session types.Session)) { manager.emmiter.On("disconnected", func(payload ...interface{}) { // Stop streaming, if everyone left diff --git a/internal/session/session.go b/internal/session/session.go index 52f1b16b..cbf75e0d 100644 --- a/internal/session/session.go +++ b/internal/session/session.go @@ -45,7 +45,6 @@ func (session *SessionCtx) Connected() bool { func (session *SessionCtx) SetWebSocketPeer(websocket_peer types.WebSocketPeer) { session.websocket_peer = websocket_peer - session.manager.emmiter.Emit("created", session) } func (session *SessionCtx) SetWebSocketConnected(connected bool) { diff --git a/internal/types/session.go b/internal/types/session.go index cf525f51..c28475a7 100644 --- a/internal/types/session.go +++ b/internal/types/session.go @@ -46,7 +46,6 @@ type SessionManager interface { OnHost(listener func(session Session)) OnHostCleared(listener func(session Session)) - OnCreated(listener func(session Session)) OnConnected(listener func(session Session)) OnDisconnected(listener func(session Session)) diff --git a/internal/websocket/handler/session.go b/internal/websocket/handler/session.go index 2299120e..b3d761e5 100644 --- a/internal/websocket/handler/session.go +++ b/internal/websocket/handler/session.go @@ -6,10 +6,6 @@ import ( "demodesk/neko/internal/types/message" ) -func (h *MessageHandlerCtx) SessionCreated(session types.Session) error { - return nil -} - func (h *MessageHandlerCtx) SessionConnected(session types.Session) error { // create member list members := []*message.MembersListEntry{} diff --git a/internal/websocket/manager.go b/internal/websocket/manager.go index 027fe3e0..14647c57 100644 --- a/internal/websocket/manager.go +++ b/internal/websocket/manager.go @@ -49,14 +49,6 @@ type WebSocketManagerCtx struct { } func (ws *WebSocketManagerCtx) Start() { - ws.sessions.OnCreated(func(session types.Session) { - if err := ws.handler.SessionCreated(session); err != nil { - ws.logger.Warn().Str("id", session.ID()).Err(err).Msg("session created with an error") - } else { - ws.logger.Debug().Str("id", session.ID()).Msg("session created") - } - }) - ws.sessions.OnConnected(func(session types.Session) { if err := ws.handler.SessionConnected(session); err != nil { ws.logger.Warn().Str("id", session.ID()).Err(err).Msg("session connected with an error")