mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
Websocket: use event + payload
This commit is contained in:
@ -127,7 +127,7 @@ export class NekoMessages extends EventEmitter<NekoEvents> {
|
||||
Vue.set(this._state.connection.webrtc, 'video', video)
|
||||
}
|
||||
|
||||
protected async [EVENT.SIGNAL_RESTART]({ event, sdp }: message.SignalAnswer) {
|
||||
protected async [EVENT.SIGNAL_RESTART]({ sdp }: message.SignalAnswer) {
|
||||
this._log.debug('EVENT.SIGNAL_RESTART')
|
||||
this.emit('connection.webrtc.sdp', 'remote', sdp)
|
||||
|
||||
@ -139,7 +139,7 @@ export class NekoMessages extends EventEmitter<NekoEvents> {
|
||||
this.emit('connection.webrtc.sdp', 'local', localSdp)
|
||||
}
|
||||
|
||||
protected [EVENT.SIGNAL_CANDIDATE]({ event, ...candidate }: message.SignalCandidate) {
|
||||
protected [EVENT.SIGNAL_CANDIDATE](candidate: message.SignalCandidate) {
|
||||
this._log.debug('EVENT.SIGNAL_CANDIDATE')
|
||||
this._connection.webrtc.setCandidate(candidate)
|
||||
this.emit('connection.webrtc.sdp.candidate', 'remote', candidate)
|
||||
@ -218,7 +218,7 @@ export class NekoMessages extends EventEmitter<NekoEvents> {
|
||||
// Broadcast Events
|
||||
/////////////////////////////
|
||||
|
||||
protected [EVENT.BORADCAST_STATUS]({ event, url, is_active }: message.BroadcastStatus) {
|
||||
protected [EVENT.BORADCAST_STATUS]({ url, is_active }: message.BroadcastStatus) {
|
||||
this._log.debug('EVENT.BORADCAST_STATUS')
|
||||
// TODO: Handle.
|
||||
this.emit('room.broadcast.status', is_active, url)
|
||||
|
@ -72,11 +72,11 @@ export class NekoWebSocket extends EventEmitter<NekoWebSocketEvents> {
|
||||
}
|
||||
|
||||
this._log.debug(`sending event '${event}' ${payload ? `with payload: ` : ''}`, payload)
|
||||
this._ws!.send(JSON.stringify({ event, ...payload }))
|
||||
this._ws!.send(JSON.stringify({ event, payload }))
|
||||
}
|
||||
|
||||
private onMessage(e: MessageEvent) {
|
||||
const { event, ...payload } = JSON.parse(e.data)
|
||||
const { event, payload } = JSON.parse(e.data)
|
||||
|
||||
this._log.debug(`received websocket event ${event} ${payload ? `with payload: ` : ''}`, payload)
|
||||
this.emit('message', event, payload)
|
||||
|
Reference in New Issue
Block a user