From 5f6aef469a7dda49eec34742db30f13ca58afcd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Sun, 27 Mar 2022 01:16:19 +0100 Subject: [PATCH] implement settings structure. --- src/component/internal/messages.ts | 10 +++++++--- src/component/main.vue | 30 +++++++++++++++++++----------- src/component/types/events.ts | 1 + src/component/types/messages.ts | 6 ++++-- src/component/types/state.ts | 18 +++++++++++++----- 5 files changed, 44 insertions(+), 21 deletions(-) diff --git a/src/component/internal/messages.ts b/src/component/internal/messages.ts index 31a0baf9..cf4c10f8 100644 --- a/src/component/internal/messages.ts +++ b/src/component/internal/messages.ts @@ -100,8 +100,6 @@ export class NekoMessages extends EventEmitter { protected [EVENT.SYSTEM_INIT](conf: message.SystemInit) { this._localLog.debug(`EVENT.SYSTEM_INIT`) Vue.set(this._state, 'session_id', conf.session_id) - Vue.set(this._state.control, 'implicit_hosting', conf.implicit_hosting) - Vue.set(this._state.cursors, 'enabled', conf.inactive_cursors) Vue.set(this._state.connection, 'screencast', conf.screencast_enabled) Vue.set(this._state.connection.webrtc, 'videos', conf.webrtc.videos) @@ -111,6 +109,7 @@ export class NekoMessages extends EventEmitter { this[EVENT.SCREEN_UPDATED](conf.screen_size) this[EVENT.CONTROL_HOST](conf.control_host) + this[EVENT.SYSTEM_SETTINGS](conf.settings) } protected [EVENT.SYSTEM_ADMIN]({ screen_sizes_list, broadcast_status }: message.SystemAdmin) { @@ -130,6 +129,11 @@ export class NekoMessages extends EventEmitter { this[EVENT.BORADCAST_STATUS](broadcast_status) } + protected [EVENT.SYSTEM_SETTINGS](settings: message.SystemSettings) { + this._localLog.debug(`EVENT.SYSTEM_SETTINGS`) + Vue.set(this._state, 'settings', settings) + } + protected [EVENT.SYSTEM_DISCONNECT]({ message }: message.SystemDisconnect) { this._localLog.debug(`EVENT.SYSTEM_DISCONNECT`) this._connection.close(new Error(message)) @@ -229,7 +233,7 @@ export class NekoMessages extends EventEmitter { } protected [EVENT.SESSION_CURSORS](cursors: message.SessionCursor[]) { - Vue.set(this._state.cursors, 'list', cursors) + Vue.set(this._state, 'cursors', cursors) } ///////////////////////////// diff --git a/src/component/main.vue b/src/component/main.vue index fd6a1d79..0ee33de6 100644 --- a/src/component/main.vue +++ b/src/component/main.vue @@ -10,13 +10,13 @@ @imageReady="screencastReady = $event" /> - implicit_hosting: boolean - inactive_cursors: boolean + settings: Settings screencast_enabled: boolean webrtc: SystemWebRTC } diff --git a/src/component/types/state.ts b/src/component/types/state.ts index 3da47e06..f1c91013 100644 --- a/src/component/types/state.ts +++ b/src/component/types/state.ts @@ -9,6 +9,7 @@ export default interface State { screen: Screen session_id: string | null sessions: Record + settings: Settings cursors: Cursors } @@ -64,7 +65,6 @@ export interface Control { clipboard: Clipboard | null keyboard: Keyboard host_id: string | null - implicit_hosting: boolean locked: boolean } @@ -125,14 +125,22 @@ export interface Session { state: SessionState } +///////////////////////////// +// Settings +///////////////////////////// + +export interface Settings { + private_mode: boolean + implicit_hosting: boolean + inactive_cursors: boolean + merciful_reconnect: boolean +} + ///////////////////////////// // Cursors ///////////////////////////// -export interface Cursors { - enabled: boolean - list: SessionCursors[] -} +type Cursors = SessionCursors[] export interface SessionCursors { id: string