add control lock.

This commit is contained in:
Miroslav Šedivý
2022-01-30 20:55:19 +01:00
parent d5125ea8e1
commit 87766d4e41
3 changed files with 26 additions and 3 deletions

View File

@ -1,14 +1,34 @@
import Vue from 'vue'
import * as EVENT from '../types/events'
import * as message from '../types/messages'
import { NekoConnection } from './connection'
import { Control } from '../types/state'
export class NekoControl {
// eslint-disable-next-line
constructor(
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) {
this._connection.websocket.send(EVENT.CONTROL_KEYPRESS, { keysym } as message.ControlKey)
}