diff --git a/src/component/internal/control.ts b/src/component/internal/control.ts index 4efc41d2..8aa33640 100644 --- a/src/component/internal/control.ts +++ b/src/component/internal/control.ts @@ -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) } diff --git a/src/component/main.vue b/src/component/main.vue index 148bfa2a..c47f2743 100644 --- a/src/component/main.vue +++ b/src/component/main.vue @@ -14,6 +14,7 @@ :cursorDraw="inactiveCursorDrawFunction" />