42 lines
962 B
Go
Raw Permalink Normal View History

2020-01-20 16:22:24 +00:00
package websocket
import (
2021-10-05 22:38:24 +02:00
"m1k1o/neko/internal/types"
"m1k1o/neko/internal/types/event"
"m1k1o/neko/internal/types/message"
2020-01-20 16:22:24 +00:00
)
func (h *MessageHandler) chat(id string, session types.Session, payload *message.ChatReceive) error {
2020-01-24 15:47:37 +00:00
if session.Muted() {
2020-01-22 17:16:40 +00:00
return nil
}
if err := h.sessions.Broadcast(
2020-01-20 16:22:24 +00:00
message.ChatSend{
Event: event.CHAT_MESSAGE,
Content: payload.Content,
ID: id,
}, nil); err != nil {
h.logger.Warn().Err(err).Msgf("broadcasting event %s has failed", event.CONTROL_RELEASE)
2020-01-20 16:22:24 +00:00
return err
}
return nil
}
func (h *MessageHandler) chatEmote(id string, session types.Session, payload *message.EmoteReceive) error {
2020-01-24 15:47:37 +00:00
if session.Muted() {
2020-01-22 17:16:40 +00:00
return nil
}
if err := h.sessions.Broadcast(
2020-01-23 15:23:26 +00:00
message.EmoteSend{
Event: event.CHAT_EMOTE,
Emote: payload.Emote,
2020-01-20 16:22:24 +00:00
ID: id,
}, nil); err != nil {
h.logger.Warn().Err(err).Msgf("broadcasting event %s has failed", event.CONTROL_RELEASE)
2020-01-20 16:22:24 +00:00
return err
}
return nil
}