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

42 lines
962 B
Go
Raw Normal View History

2020-01-21 05:22:24 +13:00
package websocket
import (
"n.eko.moe/neko/internal/event"
"n.eko.moe/neko/internal/message"
"n.eko.moe/neko/internal/session"
)
func (h *MessageHandler) chat(id string, session *session.Session, payload *message.ChatRecieve) error {
2020-01-23 06:16:40 +13:00
if session.Muted {
return nil
}
2020-01-21 05:22:24 +13:00
if err := h.sessions.Brodcast(
message.ChatSend{
Event: event.CHAT_MESSAGE,
Content: payload.Content,
ID: id,
}, nil); err != nil {
h.logger.Warn().Err(err).Msgf("brodcasting event %s has failed", event.CONTROL_RELEASE)
return err
}
return nil
}
2020-01-24 04:23:26 +13:00
func (h *MessageHandler) chatEmote(id string, session *session.Session, payload *message.EmoteRecieve) error {
2020-01-23 06:16:40 +13:00
if session.Muted {
return nil
}
2020-01-21 05:22:24 +13:00
if err := h.sessions.Brodcast(
2020-01-24 04:23:26 +13:00
message.EmoteSend{
Event: event.CHAT_EMOTE,
Emote: payload.Emote,
2020-01-21 05:22:24 +13:00
ID: id,
}, nil); err != nil {
h.logger.Warn().Err(err).Msgf("brodcasting event %s has failed", event.CONTROL_RELEASE)
return err
}
return nil
}