mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
member -> session.
This commit is contained in:
parent
6a90cd11d2
commit
85c4f4371d
@ -27,10 +27,10 @@ export interface NekoEvents {
|
||||
['receive.unicast']: (sender: string, subject: string, body: any) => void
|
||||
['receive.broadcast']: (sender: string, subject: string, body: any) => void
|
||||
|
||||
// member events
|
||||
['member.created']: (id: string) => void
|
||||
['member.deleted']: (id: string) => void
|
||||
['member.updated']: (id: string) => void
|
||||
// session events
|
||||
['session.created']: (id: string) => void
|
||||
['session.deleted']: (id: string) => void
|
||||
['session.updated']: (id: string) => void
|
||||
|
||||
// room events
|
||||
['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) {
|
||||
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)
|
||||
|
||||
for (const id in conf.members) {
|
||||
this[EVENT.SESSION_CREATED](conf.members[id])
|
||||
for (const id in conf.sessions) {
|
||||
this[EVENT.SESSION_CREATED](conf.sessions[id])
|
||||
}
|
||||
|
||||
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)
|
||||
Vue.set(this.state.members, id, data)
|
||||
this.emit('member.created', id)
|
||||
Vue.set(this.state.sessions, id, data)
|
||||
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)
|
||||
Vue.delete(this.state.members, id)
|
||||
this.emit('member.deleted', id)
|
||||
Vue.delete(this.state.sessions, id)
|
||||
this.emit('session.deleted', id)
|
||||
}
|
||||
|
||||
protected [EVENT.SESSION_PROFILE]({ id, ...profile }: message.MemberProfile) {
|
||||
this._log.debug('EVENT.SESSION_PROFILE', id)
|
||||
Vue.set(this.state.members[id], 'profile', profile)
|
||||
this.emit('member.updated', id)
|
||||
Vue.set(this.state.sessions[id], 'profile', profile)
|
||||
this.emit('session.updated', id)
|
||||
}
|
||||
|
||||
protected [EVENT.SESSION_STATE]({ id, ...state }: message.SessionState) {
|
||||
this._log.debug('EVENT.SESSION_STATE', id)
|
||||
Vue.set(this.state.members[id], 'state', state)
|
||||
this.emit('member.updated', id)
|
||||
Vue.set(this.state.sessions[id], 'state', state)
|
||||
this.emit('session.updated', id)
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
@ -211,17 +211,17 @@ export class NekoMessages extends EventEmitter<NekoEvents> {
|
||||
// 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')
|
||||
|
||||
if (id == this.state.member_id) {
|
||||
if (id == this.state.session_id) {
|
||||
this.emit('upload.dialog.requested')
|
||||
} else {
|
||||
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.emit('upload.dialog.closed')
|
||||
}
|
||||
|
@ -10,10 +10,10 @@
|
||||
:isControling="controlling && watching"
|
||||
:cursorTag="
|
||||
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-release="websocket.send('control/release')"
|
||||
@update-kbd-modifiers="websocket.send('keyboard/modifiers', $event)"
|
||||
@ -138,8 +138,8 @@
|
||||
},
|
||||
configurations: [],
|
||||
},
|
||||
member_id: null,
|
||||
members: {},
|
||||
session_id: null,
|
||||
sessions: {},
|
||||
} as NekoState
|
||||
|
||||
public get authenticated() {
|
||||
@ -155,11 +155,11 @@
|
||||
}
|
||||
|
||||
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() {
|
||||
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.screen, 'size', { width: 1280, height: 720, rate: 30 })
|
||||
Vue.set(this.state.screen, 'configurations', [])
|
||||
Vue.set(this.state, 'member_id', null)
|
||||
Vue.set(this.state, 'members', {})
|
||||
Vue.set(this.state, 'session_id', null)
|
||||
Vue.set(this.state, 'sessions', {})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -9,10 +9,10 @@ export interface Message {
|
||||
|
||||
export interface SystemInit {
|
||||
event: string | undefined
|
||||
member_id: string
|
||||
session_id: string
|
||||
control_host: ControlHost
|
||||
screen_size: ScreenSize
|
||||
members: Record<string, MemberData>
|
||||
sessions: Record<string, SessionData>
|
||||
implicit_hosting: boolean
|
||||
}
|
||||
|
||||
@ -55,11 +55,10 @@ export interface SignalVideo {
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
// Member
|
||||
// Session
|
||||
/////////////////////////////
|
||||
|
||||
// TODO: New.
|
||||
export interface MemberID {
|
||||
export interface SessionID {
|
||||
event: string | undefined
|
||||
id: string
|
||||
}
|
||||
@ -83,7 +82,7 @@ export interface SessionState {
|
||||
is_watching: boolean
|
||||
}
|
||||
|
||||
export interface MemberData {
|
||||
export interface SessionData {
|
||||
event: string | undefined
|
||||
id: string
|
||||
profile: MemberProfile
|
||||
|
@ -3,8 +3,8 @@ export default interface State {
|
||||
video: Video
|
||||
control: Control
|
||||
screen: Screen
|
||||
member_id: string | null
|
||||
members: Record<string, Member>
|
||||
session_id: string | null
|
||||
sessions: Record<string, Session>
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
@ -84,7 +84,7 @@ export interface ScreenSize {
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
// Member
|
||||
// Session
|
||||
/////////////////////////////
|
||||
export interface MemberProfile {
|
||||
name: string
|
||||
@ -101,7 +101,7 @@ export interface SessionState {
|
||||
is_watching: boolean
|
||||
}
|
||||
|
||||
export interface Member {
|
||||
export interface Session {
|
||||
id: string
|
||||
profile: MemberProfile
|
||||
state: SessionState
|
||||
|
Loading…
Reference in New Issue
Block a user