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

@ -17,10 +17,10 @@ type Message struct {
type SystemInit struct {
Event string `json:"event,omitempty"`
MemberId string `json:"member_id"`
SessionId string `json:"session_id"`
ControlHost ControlHost `json:"control_host"`
ScreenSize ScreenSize `json:"screen_size"`
Members map[string]MemberData `json:"members"`
Sessions map[string]SessionData `json:"sessions"`
ImplicitHosting bool `json:"implicit_hosting"`
}
@ -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"`

View File

@ -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 {

View File

@ -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)

View File

@ -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(),
})
}