member -> session.

This commit is contained in:
Miroslav Šedivý 2021-03-14 00:08:52 +01:00
parent 6a90cd11d2
commit 85c4f4371d
4 changed files with 38 additions and 39 deletions

View File

@ -27,10 +27,10 @@ export interface NekoEvents {
['receive.unicast']: (sender: string, subject: string, body: any) => void ['receive.unicast']: (sender: string, subject: string, body: any) => void
['receive.broadcast']: (sender: string, subject: string, body: any) => void ['receive.broadcast']: (sender: string, subject: string, body: any) => void
// member events // session events
['member.created']: (id: string) => void ['session.created']: (id: string) => void
['member.deleted']: (id: string) => void ['session.deleted']: (id: string) => void
['member.updated']: (id: string) => void ['session.updated']: (id: string) => void
// room events // room events
['room.control.host']: (hasHost: boolean, hostID: string | undefined) => void ['room.control.host']: (hasHost: boolean, hostID: string | undefined) => void
@ -65,11 +65,11 @@ export class NekoMessages extends EventEmitter<NekoEvents> {
protected [EVENT.SYSTEM_INIT](conf: message.SystemInit) { protected [EVENT.SYSTEM_INIT](conf: message.SystemInit) {
this._log.debug('EVENT.SYSTEM_INIT') this._log.debug('EVENT.SYSTEM_INIT')
Vue.set(this.state, 'member_id', conf.member_id) Vue.set(this.state, 'session_id', conf.session_id)
Vue.set(this.state.control, 'implicit_hosting', conf.implicit_hosting) Vue.set(this.state.control, 'implicit_hosting', conf.implicit_hosting)
for (const id in conf.members) { for (const id in conf.sessions) {
this[EVENT.SESSION_CREATED](conf.members[id]) this[EVENT.SESSION_CREATED](conf.sessions[id])
} }
this[EVENT.SCREEN_UPDATED](conf.screen_size) this[EVENT.SCREEN_UPDATED](conf.screen_size)
@ -120,31 +120,31 @@ export class NekoMessages extends EventEmitter<NekoEvents> {
} }
///////////////////////////// /////////////////////////////
// Member Events // Session Events
///////////////////////////// /////////////////////////////
protected [EVENT.SESSION_CREATED]({ id, ...data }: message.MemberData) { protected [EVENT.SESSION_CREATED]({ id, ...data }: message.SessionData) {
this._log.debug('EVENT.SESSION_CREATED', id) this._log.debug('EVENT.SESSION_CREATED', id)
Vue.set(this.state.members, id, data) Vue.set(this.state.sessions, id, data)
this.emit('member.created', id) this.emit('session.created', id)
} }
protected [EVENT.SESSION_DELETED]({ id }: message.MemberID) { protected [EVENT.SESSION_DELETED]({ id }: message.SessionID) {
this._log.debug('EVENT.SESSION_DELETED', id) this._log.debug('EVENT.SESSION_DELETED', id)
Vue.delete(this.state.members, id) Vue.delete(this.state.sessions, id)
this.emit('member.deleted', id) this.emit('session.deleted', id)
} }
protected [EVENT.SESSION_PROFILE]({ id, ...profile }: message.MemberProfile) { protected [EVENT.SESSION_PROFILE]({ id, ...profile }: message.MemberProfile) {
this._log.debug('EVENT.SESSION_PROFILE', id) this._log.debug('EVENT.SESSION_PROFILE', id)
Vue.set(this.state.members[id], 'profile', profile) Vue.set(this.state.sessions[id], 'profile', profile)
this.emit('member.updated', id) this.emit('session.updated', id)
} }
protected [EVENT.SESSION_STATE]({ id, ...state }: message.SessionState) { protected [EVENT.SESSION_STATE]({ id, ...state }: message.SessionState) {
this._log.debug('EVENT.SESSION_STATE', id) this._log.debug('EVENT.SESSION_STATE', id)
Vue.set(this.state.members[id], 'state', state) Vue.set(this.state.sessions[id], 'state', state)
this.emit('member.updated', id) this.emit('session.updated', id)
} }
///////////////////////////// /////////////////////////////
@ -211,17 +211,17 @@ export class NekoMessages extends EventEmitter<NekoEvents> {
// FileChooserDialog Events // FileChooserDialog Events
///////////////////////////// /////////////////////////////
protected [EVENT.FILE_CHOOSER_DIALOG_OPENED]({ id }: message.MemberID) { protected [EVENT.FILE_CHOOSER_DIALOG_OPENED]({ id }: message.SessionID) {
this._log.debug('EVENT.FILE_CHOOSER_DIALOG_OPENED') this._log.debug('EVENT.FILE_CHOOSER_DIALOG_OPENED')
if (id == this.state.member_id) { if (id == this.state.session_id) {
this.emit('upload.dialog.requested') this.emit('upload.dialog.requested')
} else { } else {
this.emit('upload.dialog.overlay', id) this.emit('upload.dialog.overlay', id)
} }
} }
protected [EVENT.FILE_CHOOSER_DIALOG_CLOSED]({ id }: message.MemberID) { protected [EVENT.FILE_CHOOSER_DIALOG_CLOSED]({ id }: message.SessionID) {
this._log.debug('EVENT.FILE_CHOOSER_DIALOG_CLOSED') this._log.debug('EVENT.FILE_CHOOSER_DIALOG_CLOSED')
this.emit('upload.dialog.closed') this.emit('upload.dialog.closed')
} }

View File

@ -10,10 +10,10 @@
:isControling="controlling && watching" :isControling="controlling && watching"
:cursorTag=" :cursorTag="
state.control.implicit_hosting && state.control.host_id != null state.control.implicit_hosting && state.control.host_id != null
? state.members[state.control.host_id].profile.name ? state.sessions[state.control.host_id].profile.name
: '' : ''
" "
:implicitControl="state.control.implicit_hosting && state.members[state.member_id].profile.can_host" :implicitControl="state.control.implicit_hosting && state.sessions[state.session_id].profile.can_host"
@implicit-control-request="websocket.send('control/request')" @implicit-control-request="websocket.send('control/request')"
@implicit-control-release="websocket.send('control/release')" @implicit-control-release="websocket.send('control/release')"
@update-kbd-modifiers="websocket.send('keyboard/modifiers', $event)" @update-kbd-modifiers="websocket.send('keyboard/modifiers', $event)"
@ -138,8 +138,8 @@
}, },
configurations: [], configurations: [],
}, },
member_id: null, session_id: null,
members: {}, sessions: {},
} as NekoState } as NekoState
public get authenticated() { public get authenticated() {
@ -155,11 +155,11 @@
} }
public get controlling() { public get controlling() {
return this.state.control.host_id !== null && this.state.member_id === this.state.control.host_id return this.state.control.host_id !== null && this.state.session_id === this.state.control.host_id
} }
public get is_admin() { public get is_admin() {
return this.state.member_id != null ? this.state.members[this.state.member_id].profile.is_admin : false return this.state.session_id != null ? this.state.sessions[this.state.session_id].profile.is_admin : false
} }
///////////////////////////// /////////////////////////////
@ -588,8 +588,8 @@
Vue.set(this.state.control, 'implicit_hosting', false) Vue.set(this.state.control, 'implicit_hosting', false)
Vue.set(this.state.screen, 'size', { width: 1280, height: 720, rate: 30 }) Vue.set(this.state.screen, 'size', { width: 1280, height: 720, rate: 30 })
Vue.set(this.state.screen, 'configurations', []) Vue.set(this.state.screen, 'configurations', [])
Vue.set(this.state, 'member_id', null) Vue.set(this.state, 'session_id', null)
Vue.set(this.state, 'members', {}) Vue.set(this.state, 'sessions', {})
} }
} }
</script> </script>

View File

@ -9,10 +9,10 @@ export interface Message {
export interface SystemInit { export interface SystemInit {
event: string | undefined event: string | undefined
member_id: string session_id: string
control_host: ControlHost control_host: ControlHost
screen_size: ScreenSize screen_size: ScreenSize
members: Record<string, MemberData> sessions: Record<string, SessionData>
implicit_hosting: boolean implicit_hosting: boolean
} }
@ -55,11 +55,10 @@ export interface SignalVideo {
} }
///////////////////////////// /////////////////////////////
// Member // Session
///////////////////////////// /////////////////////////////
// TODO: New. export interface SessionID {
export interface MemberID {
event: string | undefined event: string | undefined
id: string id: string
} }
@ -83,7 +82,7 @@ export interface SessionState {
is_watching: boolean is_watching: boolean
} }
export interface MemberData { export interface SessionData {
event: string | undefined event: string | undefined
id: string id: string
profile: MemberProfile profile: MemberProfile

View File

@ -3,8 +3,8 @@ export default interface State {
video: Video video: Video
control: Control control: Control
screen: Screen screen: Screen
member_id: string | null session_id: string | null
members: Record<string, Member> sessions: Record<string, Session>
} }
///////////////////////////// /////////////////////////////
@ -84,7 +84,7 @@ export interface ScreenSize {
} }
///////////////////////////// /////////////////////////////
// Member // Session
///////////////////////////// /////////////////////////////
export interface MemberProfile { export interface MemberProfile {
name: string name: string
@ -101,7 +101,7 @@ export interface SessionState {
is_watching: boolean is_watching: boolean
} }
export interface Member { export interface Session {
id: string id: string
profile: MemberProfile profile: MemberProfile
state: SessionState state: SessionState