add room.settings.updated.

This commit is contained in:
Miroslav Šedivý 2024-05-06 20:01:58 +02:00
parent 17b6493832
commit 2536b49568
3 changed files with 16 additions and 6 deletions

View File

@ -6,6 +6,7 @@ import type { AxiosProgressEvent } from 'axios'
import { Logger } from '../utils/logger' import { Logger } from '../utils/logger'
import { NekoConnection } from './connection' import { NekoConnection } from './connection'
import type NekoState from '../types/state' import type NekoState from '../types/state'
import type { Settings } from '../types/state'
export interface NekoEvents { export interface NekoEvents {
// connection events // connection events
@ -36,7 +37,8 @@ export interface NekoEvents {
// room events // room events
['room.control.host']: (hasHost: boolean, hostID?: string) => void ['room.control.host']: (hasHost: boolean, hostID?: string) => void
['room.screen.updated']: (width: number, height: number, rate: number, id?: string) => void ['room.screen.updated']: (width: number, height: number, rate: number, id: string) => void
['room.settings.updated']: (settings: Settings, id: string) => void
['room.clipboard.updated']: (text: string) => void ['room.clipboard.updated']: (text: string) => void
['room.broadcast.status']: (isActive: boolean, url?: string) => void ['room.broadcast.status']: (isActive: boolean, url?: string) => void
@ -113,9 +115,10 @@ export class NekoMessages extends EventEmitter<NekoEvents> {
this[EVENT.SESSION_CREATED](conf.sessions[id]) this[EVENT.SESSION_CREATED](conf.sessions[id])
} }
this[EVENT.SCREEN_UPDATED](conf.screen_size) const { width, height, rate } = conf.screen_size
this._state.screen.size = { width, height, rate } // TODO: Vue.Set
this[EVENT.CONTROL_HOST](conf.control_host) this[EVENT.CONTROL_HOST](conf.control_host)
this[EVENT.SYSTEM_SETTINGS](conf.settings) this._state.settings = conf.settings // TODO: Vue.Set
} }
protected [EVENT.SYSTEM_ADMIN]({ screen_sizes_list, broadcast_status }: message.SystemAdmin) { protected [EVENT.SYSTEM_ADMIN]({ screen_sizes_list, broadcast_status }: message.SystemAdmin) {
@ -135,9 +138,10 @@ export class NekoMessages extends EventEmitter<NekoEvents> {
this[EVENT.BORADCAST_STATUS](broadcast_status) this[EVENT.BORADCAST_STATUS](broadcast_status)
} }
protected [EVENT.SYSTEM_SETTINGS](settings: message.SystemSettings) { protected [EVENT.SYSTEM_SETTINGS]({ id, ...settings }: message.SystemSettingsUpdate) {
this._localLog.debug(`EVENT.SYSTEM_SETTINGS`) this._localLog.debug(`EVENT.SYSTEM_SETTINGS`)
this._state.settings = settings // TODO: Vue.Set this._state.settings = settings // TODO: Vue.Set
this.emit('room.settings.updated', settings, id)
} }
protected [EVENT.SYSTEM_DISCONNECT]({ message }: message.SystemDisconnect) { protected [EVENT.SYSTEM_DISCONNECT]({ message }: message.SystemDisconnect) {

View File

@ -6,7 +6,9 @@ import type { PeerRequest, PeerVideo, PeerAudio } from './webrtc'
// System // System
///////////////////////////// /////////////////////////////
export interface SystemSettings extends Settings {} export interface SystemSettingsUpdate extends Settings {
id: string
}
export interface SystemWebRTC { export interface SystemWebRTC {
videos: string[] videos: string[]
@ -142,7 +144,7 @@ export interface ControlTouch extends Partial<ControlPos> {
///////////////////////////// /////////////////////////////
export interface ScreenSizeUpdate extends ScreenSize { export interface ScreenSizeUpdate extends ScreenSize {
id?: string id: string
} }
///////////////////////////// /////////////////////////////

View File

@ -347,6 +347,7 @@ import { ref, shallowRef, computed, onMounted } from 'vue'
import type { AxiosProgressEvent } from 'axios' import type { AxiosProgressEvent } from 'axios'
import NekoCanvas from '@/component/main.vue' import NekoCanvas from '@/component/main.vue'
import type { Settings } from '@/component/types/state'
import NekoHeader from './components/header.vue' import NekoHeader from './components/header.vue'
import NekoConnect from './components/connect.vue' import NekoConnect from './components/connect.vue'
import NekoControls from './components/controls.vue' import NekoControls from './components/controls.vue'
@ -502,6 +503,9 @@ onMounted(() => {
neko.value!.events.on('room.clipboard.updated', (text: string) => { neko.value!.events.on('room.clipboard.updated', (text: string) => {
console.log('room.clipboard.updated', text) console.log('room.clipboard.updated', text)
}) })
neko.value!.events.on('room.settings.updated', (settings: Settings, id: string) => {
console.log('room.settings.updated', settings, 'by', id)
})
neko.value!.events.on('room.broadcast.status', (isActive: boolean, url?: string) => { neko.value!.events.on('room.broadcast.status', (isActive: boolean, url?: string) => {
console.log('room.broadcast.status', isActive, url) console.log('room.broadcast.status', isActive, url)
}) })