send / receive message.

This commit is contained in:
Miroslav Šedivý 2021-01-28 16:08:17 +01:00
parent 115b8b93d0
commit 962b84d89e
4 changed files with 38 additions and 0 deletions

View File

@ -22,6 +22,8 @@ export interface NekoEvents {
['screen.updated']: (width: number, height: number, rate: number) => void ['screen.updated']: (width: number, height: number, rate: number) => void
['clipboard.updated']: (text: string) => void ['clipboard.updated']: (text: string) => void
['broadcast.status']: (isActive: boolean, url: string | undefined) => void ['broadcast.status']: (isActive: boolean, url: string | undefined) => void
['receive.unicast']: (sender: string, subject: string, body: string) => void
['receive.broadcast']: (sender: string, subject: string, body: string) => void
['file_chooser_dialog.requested']: () => void ['file_chooser_dialog.requested']: () => void
['file_chooser_dialog.overlay']: (id: string) => void ['file_chooser_dialog.overlay']: (id: string) => void
['file_chooser_dialog.closed']: () => void ['file_chooser_dialog.closed']: () => void
@ -177,6 +179,20 @@ export class NekoMessages extends EventEmitter<NekoEvents> {
this.emit('broadcast.status', is_active, url) this.emit('broadcast.status', is_active, url)
} }
/////////////////////////////
// Send Events
/////////////////////////////
protected [EVENT.SEND_UNICAST]({ sender, subject, body }: message.SendMessage) {
this._log.debug('EVENT.SEND_UNICAST')
this.emit('receive.unicast', sender, subject, body)
}
protected [EVENT.SEND_BROADCAST]({ sender, subject, body }: message.SendMessage) {
this._log.debug('EVENT.BORADCAST_STATUS')
this.emit('receive.broadcast', sender, subject, body)
}
///////////////////////////// /////////////////////////////
// FileChooserDialog Events // FileChooserDialog Events
///////////////////////////// /////////////////////////////

View File

@ -230,6 +230,14 @@
this.websocket.send('screen/set', { width, height, rate }) this.websocket.send('screen/set', { width, height, rate })
} }
public sendUnicast(receiver: string, subject: string, body: string) {
this.websocket.send('send/unicast', { receiver, subject, body })
}
public sendBroadcast(subject: string, body: string) {
this.websocket.send('send/broadcast', { subject, body })
}
public get room(): RoomApi { public get room(): RoomApi {
return this.api.room return this.api.room
} }

View File

@ -32,5 +32,8 @@ export const CURSOR_IMAGE = 'cursor/image'
export const BORADCAST_STATUS = 'broadcast/status' export const BORADCAST_STATUS = 'broadcast/status'
export const SEND_UNICAST = 'send/unicast'
export const SEND_BROADCAST = 'send/broadcast'
export const FILE_CHOOSER_DIALOG_OPENED = 'file_chooser_dialog/opened' export const FILE_CHOOSER_DIALOG_OPENED = 'file_chooser_dialog/opened'
export const FILE_CHOOSER_DIALOG_CLOSED = 'file_chooser_dialog/closed' export const FILE_CHOOSER_DIALOG_CLOSED = 'file_chooser_dialog/closed'

View File

@ -170,3 +170,14 @@ export interface BroadcastStatus {
is_active: boolean is_active: boolean
url: string | undefined url: string | undefined
} }
/////////////////////////////
// Send
/////////////////////////////
export interface SendMessage {
event: string | undefined
sender: string
subject: string
body: string
}