member -> session.

This commit is contained in:
Miroslav Šedivý 2021-03-14 00:05:31 +01:00
parent fa687480a9
commit fb2078e1ff
4 changed files with 18 additions and 20 deletions

View File

@ -16,12 +16,12 @@ type Message struct {
///////////////////////////// /////////////////////////////
type SystemInit struct { type SystemInit struct {
Event string `json:"event,omitempty"` Event string `json:"event,omitempty"`
MemberId string `json:"member_id"` SessionId string `json:"session_id"`
ControlHost ControlHost `json:"control_host"` ControlHost ControlHost `json:"control_host"`
ScreenSize ScreenSize `json:"screen_size"` ScreenSize ScreenSize `json:"screen_size"`
Members map[string]MemberData `json:"members"` Sessions map[string]SessionData `json:"sessions"`
ImplicitHosting bool `json:"implicit_hosting"` ImplicitHosting bool `json:"implicit_hosting"`
} }
type SystemAdmin struct { type SystemAdmin struct {
@ -64,10 +64,10 @@ type SignalVideo struct {
} }
///////////////////////////// /////////////////////////////
// Member // Session
///////////////////////////// /////////////////////////////
type MemberID struct { type SessionID struct {
Event string `json:"event,omitempty"` Event string `json:"event,omitempty"`
ID string `json:"id"` ID string `json:"id"`
} }
@ -84,7 +84,7 @@ type SessionState struct {
*types.SessionState *types.SessionState
} }
type MemberData struct { type SessionData struct {
Event string `json:"event,omitempty"` Event string `json:"event,omitempty"`
ID string `json:"id"` ID string `json:"id"`
Profile types.MemberProfile `json:"profile"` Profile types.MemberProfile `json:"profile"`

View File

@ -22,7 +22,7 @@ func (manager *WebSocketManagerCtx) fileChooserDialogEvents() {
activeSession = host activeSession = host
go manager.sessions.Broadcast(message.MemberID{ go manager.sessions.Broadcast(message.SessionID{
Event: event.FILE_CHOOSER_DIALOG_OPENED, Event: event.FILE_CHOOSER_DIALOG_OPENED,
ID: host.ID(), ID: host.ID(),
}, nil) }, nil)
@ -34,7 +34,7 @@ func (manager *WebSocketManagerCtx) fileChooserDialogEvents() {
activeSession = nil activeSession = nil
go manager.sessions.Broadcast(message.MemberID{ go manager.sessions.Broadcast(message.SessionID{
Event: event.FILE_CHOOSER_DIALOG_CLOSED, Event: event.FILE_CHOOSER_DIALOG_CLOSED,
}, nil) }, nil)
}) })
@ -45,7 +45,7 @@ func (manager *WebSocketManagerCtx) fileChooserDialogEvents() {
return return
} }
if err := session.Send(message.MemberID{ if err := session.Send(message.SessionID{
Event: event.FILE_CHOOSER_DIALOG_OPENED, Event: event.FILE_CHOOSER_DIALOG_OPENED,
ID: activeSession.ID(), ID: activeSession.ID(),
}); err != nil { }); err != nil {

View File

@ -8,7 +8,7 @@ import (
func (h *MessageHandlerCtx) SessionCreated(session types.Session) error { func (h *MessageHandlerCtx) SessionCreated(session types.Session) error {
h.sessions.Broadcast( h.sessions.Broadcast(
message.MemberData{ message.SessionData{
Event: event.SESSION_CREATED, Event: event.SESSION_CREATED,
ID: session.ID(), ID: session.ID(),
Profile: session.GetProfile(), Profile: session.GetProfile(),
@ -20,7 +20,7 @@ func (h *MessageHandlerCtx) SessionCreated(session types.Session) error {
func (h *MessageHandlerCtx) SessionDeleted(session types.Session) error { func (h *MessageHandlerCtx) SessionDeleted(session types.Session) error {
h.sessions.Broadcast( h.sessions.Broadcast(
message.MemberID{ message.SessionID{
Event: event.SESSION_DELETED, Event: event.SESSION_DELETED,
ID: session.ID(), ID: session.ID(),
}, nil) }, nil)

View File

@ -24,10 +24,10 @@ func (h *MessageHandlerCtx) systemInit(session types.Session) error {
} }
// TODO: Sessions. // TODO: Sessions.
members := map[string]message.MemberData{} sessions := map[string]message.SessionData{}
for _, session := range h.sessions.List() { for _, session := range h.sessions.List() {
sessionId := session.ID() sessionId := session.ID()
members[sessionId] = message.MemberData{ sessions[sessionId] = message.SessionData{
ID: sessionId, ID: sessionId,
Profile: session.GetProfile(), Profile: session.GetProfile(),
State: session.GetState(), State: session.GetState(),
@ -37,16 +37,14 @@ func (h *MessageHandlerCtx) systemInit(session types.Session) error {
return session.Send( return session.Send(
message.SystemInit{ message.SystemInit{
Event: event.SYSTEM_INIT, Event: event.SYSTEM_INIT,
// TODO: Session ID. SessionId: session.ID(),
MemberId: session.ID(),
ControlHost: controlHost, ControlHost: controlHost,
ScreenSize: message.ScreenSize{ ScreenSize: message.ScreenSize{
Width: size.Width, Width: size.Width,
Height: size.Height, Height: size.Height,
Rate: size.Rate, Rate: size.Rate,
}, },
// TODO: Sessions. Sessions: sessions,
Members: members,
ImplicitHosting: h.sessions.ImplicitHosting(), ImplicitHosting: h.sessions.ImplicitHosting(),
}) })
} }