From bdd8bdab72e43a9bff7ab5a13e01d3b9bcf26c56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Tue, 1 Dec 2020 22:56:08 +0100 Subject: [PATCH] members as map. --- internal/types/message/messages.go | 10 +++++----- internal/websocket/handler/system.go | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/types/message/messages.go b/internal/types/message/messages.go index e13cdacb..37b16bb9 100644 --- a/internal/types/message/messages.go +++ b/internal/types/message/messages.go @@ -10,11 +10,11 @@ type Message struct { ///////////////////////////// type SystemInit struct { - Event string `json:"event,omitempty"` - MemberId string `json:"member_id"` - ControlHost ControlHost `json:"control_host"` - ScreenSize ScreenSize `json:"screen_size"` - Members []MemberData `json:"members"` + Event string `json:"event,omitempty"` + MemberId string `json:"member_id"` + ControlHost ControlHost `json:"control_host"` + ScreenSize ScreenSize `json:"screen_size"` + Members map[string]MemberData `json:"members"` } type SystemAdmin struct { diff --git a/internal/websocket/handler/system.go b/internal/websocket/handler/system.go index 3d28205e..81684499 100644 --- a/internal/websocket/handler/system.go +++ b/internal/websocket/handler/system.go @@ -23,13 +23,13 @@ func (h *MessageHandlerCtx) systemInit(session types.Session) error { return nil } - members := []message.MemberData{} + members := map[string]message.MemberData{} for _, session := range h.sessions.Members() { - members = append(members, message.MemberData{ + members[session.ID()] = message.MemberData{ ID: session.ID(), Name: session.Name(), IsAdmin: session.Admin(), - }) + } } return session.Send(