From fb2078e1ff4b22103a551948fdd7f49294f00042 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Sun, 14 Mar 2021 00:05:31 +0100 Subject: [PATCH] member -> session. --- internal/types/message/messages.go | 18 +++++++++--------- internal/websocket/filechooserdialog.go | 6 +++--- internal/websocket/handler/session.go | 4 ++-- internal/websocket/handler/system.go | 10 ++++------ 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/internal/types/message/messages.go b/internal/types/message/messages.go index 4edfa7a7..f6b6f112 100644 --- a/internal/types/message/messages.go +++ b/internal/types/message/messages.go @@ -16,12 +16,12 @@ 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 map[string]MemberData `json:"members"` - ImplicitHosting bool `json:"implicit_hosting"` + Event string `json:"event,omitempty"` + SessionId string `json:"session_id"` + ControlHost ControlHost `json:"control_host"` + ScreenSize ScreenSize `json:"screen_size"` + Sessions map[string]SessionData `json:"sessions"` + ImplicitHosting bool `json:"implicit_hosting"` } type SystemAdmin struct { @@ -64,10 +64,10 @@ type SignalVideo struct { } ///////////////////////////// -// Member +// Session ///////////////////////////// -type MemberID struct { +type SessionID struct { Event string `json:"event,omitempty"` ID string `json:"id"` } @@ -84,7 +84,7 @@ type SessionState struct { *types.SessionState } -type MemberData struct { +type SessionData struct { Event string `json:"event,omitempty"` ID string `json:"id"` Profile types.MemberProfile `json:"profile"` diff --git a/internal/websocket/filechooserdialog.go b/internal/websocket/filechooserdialog.go index 10465040..08bd0762 100644 --- a/internal/websocket/filechooserdialog.go +++ b/internal/websocket/filechooserdialog.go @@ -22,7 +22,7 @@ func (manager *WebSocketManagerCtx) fileChooserDialogEvents() { activeSession = host - go manager.sessions.Broadcast(message.MemberID{ + go manager.sessions.Broadcast(message.SessionID{ Event: event.FILE_CHOOSER_DIALOG_OPENED, ID: host.ID(), }, nil) @@ -34,7 +34,7 @@ func (manager *WebSocketManagerCtx) fileChooserDialogEvents() { activeSession = nil - go manager.sessions.Broadcast(message.MemberID{ + go manager.sessions.Broadcast(message.SessionID{ Event: event.FILE_CHOOSER_DIALOG_CLOSED, }, nil) }) @@ -45,7 +45,7 @@ func (manager *WebSocketManagerCtx) fileChooserDialogEvents() { return } - if err := session.Send(message.MemberID{ + if err := session.Send(message.SessionID{ Event: event.FILE_CHOOSER_DIALOG_OPENED, ID: activeSession.ID(), }); err != nil { diff --git a/internal/websocket/handler/session.go b/internal/websocket/handler/session.go index 6bb0a16f..fec66c55 100644 --- a/internal/websocket/handler/session.go +++ b/internal/websocket/handler/session.go @@ -8,7 +8,7 @@ import ( func (h *MessageHandlerCtx) SessionCreated(session types.Session) error { h.sessions.Broadcast( - message.MemberData{ + message.SessionData{ Event: event.SESSION_CREATED, ID: session.ID(), Profile: session.GetProfile(), @@ -20,7 +20,7 @@ func (h *MessageHandlerCtx) SessionCreated(session types.Session) error { func (h *MessageHandlerCtx) SessionDeleted(session types.Session) error { h.sessions.Broadcast( - message.MemberID{ + message.SessionID{ Event: event.SESSION_DELETED, ID: session.ID(), }, nil) diff --git a/internal/websocket/handler/system.go b/internal/websocket/handler/system.go index f38e86e1..ac3f71b1 100644 --- a/internal/websocket/handler/system.go +++ b/internal/websocket/handler/system.go @@ -24,10 +24,10 @@ func (h *MessageHandlerCtx) systemInit(session types.Session) error { } // TODO: Sessions. - members := map[string]message.MemberData{} + sessions := map[string]message.SessionData{} for _, session := range h.sessions.List() { sessionId := session.ID() - members[sessionId] = message.MemberData{ + sessions[sessionId] = message.SessionData{ ID: sessionId, Profile: session.GetProfile(), State: session.GetState(), @@ -37,16 +37,14 @@ func (h *MessageHandlerCtx) systemInit(session types.Session) error { return session.Send( message.SystemInit{ Event: event.SYSTEM_INIT, - // TODO: Session ID. - MemberId: session.ID(), + SessionId: session.ID(), ControlHost: controlHost, ScreenSize: message.ScreenSize{ Width: size.Width, Height: size.Height, Rate: size.Rate, }, - // TODO: Sessions. - Members: members, + Sessions: sessions, ImplicitHosting: h.sessions.ImplicitHosting(), }) }