sessions: switch to settings struct.

This commit is contained in:
Miroslav Šedivý
2022-03-27 00:08:06 +01:00
parent d004ddd68f
commit 81867d811b
9 changed files with 113 additions and 80 deletions

View File

@ -3,6 +3,7 @@ package event
const (
SYSTEM_INIT = "system/init"
SYSTEM_ADMIN = "system/admin"
SYSTEM_SETTINGS = "system/settings"
SYSTEM_LOGS = "system/logs"
SYSTEM_DISCONNECT = "system/disconnect"
)

View File

@ -19,10 +19,13 @@ type SystemInit struct {
ControlHost ControlHost `json:"control_host"`
ScreenSize ScreenSize `json:"screen_size"`
Sessions map[string]SessionData `json:"sessions"`
ImplicitHosting bool `json:"implicit_hosting"`
InactiveCursors bool `json:"inactive_cursors"`
Settings types.Settings `json:"settings"`
ScreencastEnabled bool `json:"screencast_enabled"`
WebRTC SystemWebRTC `json:"webrtc"`
// TODO: Left for compatibility with old client, remove.
ImplicitHosting bool `json:"implicit_hosting"`
InactiveCursors bool `json:"inactive_cursors"`
}
type SystemAdmin struct {

View File

@ -22,6 +22,13 @@ type SessionState struct {
IsWatching bool `json:"is_watching"`
}
type Settings struct {
PrivateMode bool `json:"private_mode"`
ImplicitHosting bool `json:"implicit_hosting"`
InactiveCursors bool `json:"inactive_cursors"`
MercifulReconnect bool `json:"merciful_reconnect"`
}
type Session interface {
ID() string
Profile() MemberProfile
@ -56,9 +63,6 @@ type SessionManager interface {
GetHost() Session
ClearHost()
SetPrivateMode(isPrivateMode bool)
PrivateMode() bool
SetCursor(cursor Cursor, session Session)
PopCursors() map[Session][]Cursor
@ -73,12 +77,11 @@ type SessionManager interface {
OnProfileChanged(listener func(session Session))
OnStateChanged(listener func(session Session))
OnHostChanged(listener func(session Session))
OnPrivateModeChanged(listener func(isPrivateMode bool))
OnSettingsChanged(listener func(new Settings, old Settings))
ImplicitHosting() bool
InactiveCursors() bool
UpdateSettings(Settings)
Settings() Settings
CookieEnabled() bool
MercifulReconnect() bool
CookieSetToken(w http.ResponseWriter, token string)
CookieClearToken(w http.ResponseWriter, r *http.Request)