bug fixes.

This commit is contained in:
Miroslav Šedivý 2020-11-01 16:37:00 +01:00
parent 5d906e0a8b
commit 9559edf4d4
3 changed files with 18 additions and 17 deletions

View File

@ -41,7 +41,10 @@ type MembersListEntry struct {
type Member struct {
Event string `json:"event"`
Member *MembersListEntry
ID string `json:"id"`
Name string `json:"displayname"`
Admin bool `json:"admin"`
Muted bool `json:"muted"`
}
type MemberDisconnected struct {

View File

@ -69,12 +69,10 @@ func (h *MessageHandlerCtx) SessionConnected(session types.Session) error {
if err := h.sessions.Broadcast(
message.Member{
Event: event.MEMBER_CONNECTED,
Member: &message.MembersListEntry{
ID: session.ID(),
Name: session.Name(),
Admin: session.Admin(),
Muted: session.Muted(),
},
}, nil); err != nil {
h.logger.Warn().Err(err).Msgf("broadcasting event %s has failed", event.CONTROL_RELEASE)
return err

View File

@ -231,11 +231,7 @@ func (ws *WebSocketManagerCtx) handle(connection *websocket.Conn, id string) {
for {
_, raw, err := connection.ReadMessage()
if err == nil {
bytes <- raw
continue
}
if err != nil {
if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway, websocket.CloseAbnormalClosure) {
ws.logger.Warn().Err(err).Msg("read message error")
} else {
@ -243,6 +239,10 @@ func (ws *WebSocketManagerCtx) handle(connection *websocket.Conn, id string) {
}
close(cancel)
break
}
bytes <- raw
}
}()