move control events to own emitter.

This commit is contained in:
Miroslav Šedivý 2022-01-30 21:01:14 +01:00
parent 87766d4e41
commit 7d779396ba
3 changed files with 11 additions and 7 deletions

View File

@ -3,15 +3,23 @@ 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 EventEmitter from 'eventemitter3'
import { NekoConnection } from './connection' import { NekoConnection } from './connection'
import { Control } from '../types/state' import { Control } from '../types/state'
export class NekoControl { export interface NekoControlEvents {
['overlay.click']: () => void
['overlay.contextmenu']: () => void
}
export class NekoControl extends EventEmitter<NekoControlEvents> {
// eslint-disable-next-line // eslint-disable-next-line
constructor( constructor(
private readonly _connection: NekoConnection, private readonly _connection: NekoConnection,
private readonly _state: Control, private readonly _state: Control,
) {} ) {
super()
}
public lock() { public lock() {
Vue.set(this._state, 'locked', true) Vue.set(this._state, 'locked', true)

View File

@ -39,10 +39,6 @@ export interface NekoEvents {
['room.screen.updated']: (width: number, height: number, rate: number) => void ['room.screen.updated']: (width: number, height: number, rate: number) => void
['room.clipboard.updated']: (text: string) => void ['room.clipboard.updated']: (text: string) => void
['room.broadcast.status']: (isActive: boolean, url?: string) => void ['room.broadcast.status']: (isActive: boolean, url?: string) => void
// overlay events
['overlay.click']: () => void
['overlay.contextmenu']: () => void
} }
export class NekoMessages extends EventEmitter<NekoEvents> { export class NekoMessages extends EventEmitter<NekoEvents> {

View File

@ -29,7 +29,7 @@
@implicitControlRelease="control.release()" @implicitControlRelease="control.release()"
@updateKeyboardModifiers="updateKeyboardModifiers($event)" @updateKeyboardModifiers="updateKeyboardModifiers($event)"
@uploadDrop="uploadDrop($event)" @uploadDrop="uploadDrop($event)"
@onAction="events.emit('overlay.' + $event)" @onAction="control.emit('overlay.' + $event)"
/> />
</div> </div>
</div> </div>