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 { type Member struct {
Event string `json:"event"` 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 { type MemberDisconnected struct {

View File

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

View File

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