Archived
2
0
This repository has been archived on 2024-06-24. You can view files and clone it, but cannot push or open issues or pull requests.
neko-custom/server/internal/websocket/chat.go
Miroslav Šedivý 1ff743c598 rename package.
2021-10-05 22:38:24 +02:00

42 lines
962 B
Go

package websocket
import (
"m1k1o/neko/internal/types"
"m1k1o/neko/internal/types/event"
"m1k1o/neko/internal/types/message"
)
func (h *MessageHandler) chat(id string, session types.Session, payload *message.ChatReceive) error {
if session.Muted() {
return nil
}
if err := h.sessions.Broadcast(
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)
return err
}
return nil
}
func (h *MessageHandler) chatEmote(id string, session types.Session, payload *message.EmoteReceive) error {
if session.Muted() {
return nil
}
if err := h.sessions.Broadcast(
message.EmoteSend{
Event: event.CHAT_EMOTE,
Emote: payload.Emote,
ID: id,
}, nil); err != nil {
h.logger.Warn().Err(err).Msgf("broadcasting event %s has failed", event.CONTROL_RELEASE)
return err
}
return nil
}