mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
add control lock.
This commit is contained in:
parent
d5125ea8e1
commit
87766d4e41
@ -1,14 +1,34 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
|
||||||
import * as EVENT from '../types/events'
|
import * as EVENT from '../types/events'
|
||||||
import * as message from '../types/messages'
|
import * as message from '../types/messages'
|
||||||
|
|
||||||
import { NekoConnection } from './connection'
|
import { NekoConnection } from './connection'
|
||||||
|
import { Control } from '../types/state'
|
||||||
|
|
||||||
export class NekoControl {
|
export class NekoControl {
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
constructor(
|
constructor(
|
||||||
private readonly _connection: NekoConnection,
|
private readonly _connection: NekoConnection,
|
||||||
|
private readonly _state: Control,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
public lock() {
|
||||||
|
Vue.set(this._state, 'locked', true)
|
||||||
|
}
|
||||||
|
|
||||||
|
public unlock() {
|
||||||
|
Vue.set(this._state, 'locked', false)
|
||||||
|
}
|
||||||
|
|
||||||
|
public request() {
|
||||||
|
this._connection.websocket.send(EVENT.CONTROL_REQUEST)
|
||||||
|
}
|
||||||
|
|
||||||
|
public release() {
|
||||||
|
this._connection.websocket.send(EVENT.CONTROL_RELEASE)
|
||||||
|
}
|
||||||
|
|
||||||
public keypress(keysym: number) {
|
public keypress(keysym: number) {
|
||||||
this._connection.websocket.send(EVENT.CONTROL_KEYPRESS, { keysym } as message.ControlKey)
|
this._connection.websocket.send(EVENT.CONTROL_KEYPRESS, { keysym } as message.ControlKey)
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
:cursorDraw="inactiveCursorDrawFunction"
|
:cursorDraw="inactiveCursorDrawFunction"
|
||||||
/>
|
/>
|
||||||
<neko-overlay
|
<neko-overlay
|
||||||
|
:style="{ pointerEvents: state.control.locked ? 'none' : 'auto' }"
|
||||||
:sessions="state.sessions"
|
:sessions="state.sessions"
|
||||||
:hostId="state.control.host_id"
|
:hostId="state.control.host_id"
|
||||||
:webrtc="connection.webrtc"
|
:webrtc="connection.webrtc"
|
||||||
@ -24,8 +25,8 @@
|
|||||||
:cursorDraw="cursorDrawFunction"
|
:cursorDraw="cursorDrawFunction"
|
||||||
:implicitControl="state.control.implicit_hosting && state.sessions[state.session_id].profile.can_host"
|
:implicitControl="state.control.implicit_hosting && state.sessions[state.session_id].profile.can_host"
|
||||||
:inactiveCursors="state.cursors.enabled && state.sessions[state.session_id].profile.sends_inactive_cursor"
|
:inactiveCursors="state.cursors.enabled && state.sessions[state.session_id].profile.sends_inactive_cursor"
|
||||||
@implicitControlRequest="connection.websocket.send('control/request')"
|
@implicitControlRequest="control.request()"
|
||||||
@implicitControlRelease="connection.websocket.send('control/release')"
|
@implicitControlRelease="control.release()"
|
||||||
@updateKeyboardModifiers="updateKeyboardModifiers($event)"
|
@updateKeyboardModifiers="updateKeyboardModifiers($event)"
|
||||||
@uploadDrop="uploadDrop($event)"
|
@uploadDrop="uploadDrop($event)"
|
||||||
@onAction="events.emit('overlay.' + $event)"
|
@onAction="events.emit('overlay.' + $event)"
|
||||||
@ -161,6 +162,7 @@
|
|||||||
},
|
},
|
||||||
host_id: null,
|
host_id: null,
|
||||||
implicit_hosting: false,
|
implicit_hosting: false,
|
||||||
|
locked: false,
|
||||||
},
|
},
|
||||||
screen: {
|
screen: {
|
||||||
size: {
|
size: {
|
||||||
@ -391,7 +393,7 @@
|
|||||||
this.connection.websocket.send(EVENT.SEND_BROADCAST, { subject, body })
|
this.connection.websocket.send(EVENT.SEND_BROADCAST, { subject, body })
|
||||||
}
|
}
|
||||||
|
|
||||||
public control = new NekoControl(this.connection)
|
public control = new NekoControl(this.connection, this.state.control)
|
||||||
|
|
||||||
public get room(): RoomApi {
|
public get room(): RoomApi {
|
||||||
return this.api.room
|
return this.api.room
|
||||||
|
@ -64,6 +64,7 @@ export interface Control {
|
|||||||
keyboard: Keyboard
|
keyboard: Keyboard
|
||||||
host_id: string | null
|
host_id: string | null
|
||||||
implicit_hosting: boolean
|
implicit_hosting: boolean
|
||||||
|
locked: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Scroll {
|
export interface Scroll {
|
||||||
|
Loading…
Reference in New Issue
Block a user