mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
add control.
This commit is contained in:
parent
de62a349ed
commit
d5125ea8e1
39
src/component/internal/control.ts
Normal file
39
src/component/internal/control.ts
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
@ -71,6 +71,7 @@
|
|||||||
import { NekoApi, MembersApi, RoomApi } from './internal/api'
|
import { NekoApi, MembersApi, RoomApi } from './internal/api'
|
||||||
import { NekoConnection } from './internal/connection'
|
import { NekoConnection } from './internal/connection'
|
||||||
import { NekoMessages } from './internal/messages'
|
import { NekoMessages } from './internal/messages'
|
||||||
|
import { NekoControl } from './internal/control'
|
||||||
import { register as VideoRegister } from './internal/video'
|
import { register as VideoRegister } from './internal/video'
|
||||||
|
|
||||||
import { ReconnectorConfig } from './types/reconnector'
|
import { ReconnectorConfig } from './types/reconnector'
|
||||||
@ -390,6 +391,8 @@
|
|||||||
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 get room(): RoomApi {
|
public get room(): RoomApi {
|
||||||
return this.api.room
|
return this.api.room
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,18 @@ export const SESSION_CURSORS = 'session/cursors'
|
|||||||
export const CONTROL_HOST = 'control/host'
|
export const CONTROL_HOST = 'control/host'
|
||||||
export const CONTROL_RELEASE = 'control/release'
|
export const CONTROL_RELEASE = 'control/release'
|
||||||
export const CONTROL_REQUEST = 'control/request'
|
export const CONTROL_REQUEST = 'control/request'
|
||||||
|
// mouse
|
||||||
export const CONTROL_MOVE = 'control/move' // TODO: New. (fallback)
|
export const CONTROL_MOVE = 'control/move' // TODO: New. (fallback)
|
||||||
export const CONTROL_SCROLL = 'control/scroll' // TODO: New. (fallback)
|
export const CONTROL_SCROLL = 'control/scroll' // TODO: New. (fallback)
|
||||||
export const CONTROL_KEYDOWN = 'control/keydown' // TODO: New. (fallback)
|
// keyboard
|
||||||
export const CONTROL_KEYUP = 'control/keyup' // TODO: New. (fallback)
|
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_UPDATED = 'screen/updated'
|
||||||
export const SCREEN_SET = 'screen/set'
|
export const SCREEN_SET = 'screen/set'
|
||||||
|
@ -118,9 +118,8 @@ export interface ControlScroll {
|
|||||||
y: number
|
y: number
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: New.
|
|
||||||
export interface ControlKey {
|
export interface ControlKey {
|
||||||
key: number
|
keysym: number
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
|
Loading…
Reference in New Issue
Block a user