From 994a91886dffc281b7b6e65d1564da0bc25dff84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Mon, 30 Nov 2020 17:29:05 +0100 Subject: [PATCH] remove broadcast from websocket. --- internal/types/event/events.go | 2 -- internal/websocket/handler/broadcast.go | 44 ------------------------- internal/websocket/handler/handler.go | 9 ----- internal/websocket/handler/session.go | 5 --- 4 files changed, 60 deletions(-) delete mode 100644 internal/websocket/handler/broadcast.go diff --git a/internal/types/event/events.go b/internal/types/event/events.go index 554c9187..31743ef2 100644 --- a/internal/types/event/events.go +++ b/internal/types/event/events.go @@ -53,8 +53,6 @@ const ( const ( BORADCAST_STATUS = "broadcast/status" - BORADCAST_CREATE = "broadcast/create" // TODO: Remove. - BORADCAST_DESTROY = "broadcast/destroy" // TODO: Remove. ) const ( diff --git a/internal/websocket/handler/broadcast.go b/internal/websocket/handler/broadcast.go deleted file mode 100644 index 7eda5b5f..00000000 --- a/internal/websocket/handler/broadcast.go +++ /dev/null @@ -1,44 +0,0 @@ -package handler - -import ( - "demodesk/neko/internal/types" - "demodesk/neko/internal/types/event" - "demodesk/neko/internal/types/message" -) - -func (h *MessageHandlerCtx) boradcastCreate(session types.Session, payload *message.BroadcastCreate) error { - if !session.Admin() { - h.logger.Debug().Msg("user not admin") - return nil - } - - if err := h.capture.StartBroadcast(payload.URL); err != nil { - return err - } - - return h.boradcastStatus(session) -} - -func (h *MessageHandlerCtx) boradcastDestroy(session types.Session) error { - if !session.Admin() { - h.logger.Debug().Msg("user not admin") - return nil - } - - h.capture.StopBroadcast() - return h.boradcastStatus(session) -} - -func (h *MessageHandlerCtx) boradcastStatus(session types.Session) error { - if !session.Admin() { - h.logger.Debug().Msg("user not admin") - return nil - } - - return session.Send( - message.BroadcastStatus{ - Event: event.BORADCAST_STATUS, - IsActive: h.capture.BroadcastEnabled(), - URL: h.capture.BroadcastUrl(), - }) -} diff --git a/internal/websocket/handler/handler.go b/internal/websocket/handler/handler.go index 055e3aff..9daa01a4 100644 --- a/internal/websocket/handler/handler.go +++ b/internal/websocket/handler/handler.go @@ -85,15 +85,6 @@ func (h *MessageHandlerCtx) Message(session types.Session, raw []byte) error { return h.screenSizeChange(session, payload) }) - // Boradcast Events - case event.BORADCAST_CREATE: - payload := &message.BroadcastCreate{} - err = utils.Unmarshal(payload, raw, func() error { - return h.boradcastCreate(session, payload) - }) - case event.BORADCAST_DESTROY: - err = h.boradcastDestroy(session) - // Admin Events case event.ADMIN_CONTROL: err = h.adminControl(session) diff --git a/internal/websocket/handler/session.go b/internal/websocket/handler/session.go index 1ba9adb6..fb9a23b0 100644 --- a/internal/websocket/handler/session.go +++ b/internal/websocket/handler/session.go @@ -17,11 +17,6 @@ func (h *MessageHandlerCtx) SessionCreated(session types.Session) error { if err := h.screenConfigurations(session); err != nil { return err } - - // send broadcast status if admin - if err := h.boradcastStatus(session); err != nil { - return err - } } return nil