Skip to content

Commit

Permalink
fix typo.
Browse files Browse the repository at this point in the history
  • Loading branch information
m1k1o committed Jun 17, 2024
1 parent 5759631 commit c78d797
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions server/internal/types/event/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ const (
)

const (
BORADCAST_STATUS = "broadcast/status"
BORADCAST_CREATE = "broadcast/create"
BORADCAST_DESTROY = "broadcast/destroy"
BROADCAST_STATUS = "broadcast/status"
BROADCAST_CREATE = "broadcast/create"
BROADCAST_DESTROY = "broadcast/destroy"
)

const (
Expand Down
16 changes: 8 additions & 8 deletions server/internal/websocket/handler/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"m1k1o/neko/internal/types/message"
)

func (h *MessageHandler) boradcastCreate(session types.Session, payload *message.BroadcastCreate) error {
func (h *MessageHandler) broadcastCreate(session types.Session, payload *message.BroadcastCreate) error {
broadcast := h.capture.Broadcast()

if !session.Admin() {
Expand Down Expand Up @@ -44,14 +44,14 @@ func (h *MessageHandler) boradcastCreate(session types.Session, payload *message
}
}

if err := h.boradcastStatus(nil); err != nil {
if err := h.broadcastStatus(nil); err != nil {
return err
}

return nil
}

func (h *MessageHandler) boradcastDestroy(session types.Session) error {
func (h *MessageHandler) broadcastDestroy(session types.Session) error {
broadcast := h.capture.Broadcast()

if !session.Admin() {
Expand All @@ -70,26 +70,26 @@ func (h *MessageHandler) boradcastDestroy(session types.Session) error {

broadcast.Stop()

if err := h.boradcastStatus(nil); err != nil {
if err := h.broadcastStatus(nil); err != nil {
return err
}

return nil
}

func (h *MessageHandler) boradcastStatus(session types.Session) error {
func (h *MessageHandler) broadcastStatus(session types.Session) error {
broadcast := h.capture.Broadcast()

msg := message.BroadcastStatus{
Event: event.BORADCAST_STATUS,
Event: event.BROADCAST_STATUS,
IsActive: broadcast.Started(),
URL: broadcast.Url(),
}

// if no session, broadcast change
if session == nil {
if err := h.sessions.AdminBroadcast(msg, nil); err != nil {
h.logger.Warn().Err(err).Msgf("broadcasting event %s has failed", event.BORADCAST_STATUS)
h.logger.Warn().Err(err).Msgf("broadcasting event %s has failed", event.BROADCAST_STATUS)
return err
}

Expand All @@ -102,7 +102,7 @@ func (h *MessageHandler) boradcastStatus(session types.Session) error {
}

if err := session.Send(msg); err != nil {
h.logger.Warn().Err(err).Msgf("sending event %s has failed", event.BORADCAST_STATUS)
h.logger.Warn().Err(err).Msgf("sending event %s has failed", event.BROADCAST_STATUS)
return err
}

Expand Down
10 changes: 5 additions & 5 deletions server/internal/websocket/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,15 @@ func (h *MessageHandler) Message(id string, raw []byte) error {
return h.screenSet(id, session, payload)
}), "%s failed", header.Event)

// Boradcast Events
case event.BORADCAST_CREATE:
// Broadcast Events
case event.BROADCAST_CREATE:
payload := &message.BroadcastCreate{}
return errors.Wrapf(
utils.Unmarshal(payload, raw, func() error {
return h.boradcastCreate(session, payload)
return h.broadcastCreate(session, payload)
}), "%s failed", header.Event)
case event.BORADCAST_DESTROY:
return errors.Wrapf(h.boradcastDestroy(session), "%s failed", header.Event)
case event.BROADCAST_DESTROY:
return errors.Wrapf(h.broadcastDestroy(session), "%s failed", header.Event)

// Admin Events
case event.ADMIN_LOCK:
Expand Down
2 changes: 1 addition & 1 deletion server/internal/websocket/handler/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (h *MessageHandler) SessionCreated(id string, session types.Session) error
}

// send broadcast status if admin
if err := h.boradcastStatus(session); err != nil {
if err := h.broadcastStatus(session); err != nil {
return err
}
}
Expand Down

0 comments on commit c78d797

Please sign in to comment.