add control.

This commit is contained in:
Miroslav Šedivý 2022-01-30 19:44:27 +01:00
parent de62a349ed
commit d5125ea8e1
4 changed files with 53 additions and 4 deletions

View File

@ -0,0 +1,39 @@
import * as EVENT from '../types/events'
import * as message from '../types/messages'
import { NekoConnection } from './connection'
export class NekoControl {
// eslint-disable-next-line
constructor(
private readonly _connection: NekoConnection,
) {}
public keypress(keysym: number) {
this._connection.websocket.send(EVENT.CONTROL_KEYPRESS, { keysym } as message.ControlKey)
}
public keydown(keysym: number) {
this._connection.websocket.send(EVENT.CONTROL_KEYDOWN, { keysym } as message.ControlKey)
}
public keyup(keysym: number) {
this._connection.websocket.send(EVENT.CONTROL_KEYUP, { keysym } as message.ControlKey)
}
public cut() {
this._connection.websocket.send(EVENT.CONTROL_CUT)
}
public copy() {
this._connection.websocket.send(EVENT.CONTROL_COPY)
}
public paste() {
this._connection.websocket.send(EVENT.CONTROL_PASTE)
}
public selectAll() {
this._connection.websocket.send(EVENT.CONTROL_SELECT_ALL)
}
}

View File

@ -71,6 +71,7 @@
import { NekoApi, MembersApi, RoomApi } from './internal/api'
import { NekoConnection } from './internal/connection'
import { NekoMessages } from './internal/messages'
import { NekoControl } from './internal/control'
import { register as VideoRegister } from './internal/video'
import { ReconnectorConfig } from './types/reconnector'
@ -390,6 +391,8 @@
this.connection.websocket.send(EVENT.SEND_BROADCAST, { subject, body })
}
public control = new NekoControl(this.connection)
public get room(): RoomApi {
return this.api.room
}

View File

@ -20,10 +20,18 @@ export const SESSION_CURSORS = 'session/cursors'
export const CONTROL_HOST = 'control/host'
export const CONTROL_RELEASE = 'control/release'
export const CONTROL_REQUEST = 'control/request'
// mouse
export const CONTROL_MOVE = 'control/move' // TODO: New. (fallback)
export const CONTROL_SCROLL = 'control/scroll' // TODO: New. (fallback)
export const CONTROL_KEYDOWN = 'control/keydown' // TODO: New. (fallback)
export const CONTROL_KEYUP = 'control/keyup' // TODO: New. (fallback)
// keyboard
export const CONTROL_KEYPRESS = 'control/keypress'
export const CONTROL_KEYDOWN = 'control/keydown'
export const CONTROL_KEYUP = 'control/keyup'
// actions
export const CONTROL_CUT = 'control/cut'
export const CONTROL_COPY = 'control/copy'
export const CONTROL_PASTE = 'control/paste'
export const CONTROL_SELECT_ALL = 'control/select_all'
export const SCREEN_UPDATED = 'screen/updated'
export const SCREEN_SET = 'screen/set'

View File

@ -118,9 +118,8 @@ export interface ControlScroll {
y: number
}
// TODO: New.
export interface ControlKey {
key: number
keysym: number
}
/////////////////////////////