connection type event.

This commit is contained in:
Miroslav Šedivý 2021-08-10 19:15:44 +02:00
parent 3d48152ccf
commit d3d37de009
2 changed files with 14 additions and 7 deletions

View File

@ -10,6 +10,7 @@ import NekoState from '../types/state'
export interface NekoEvents { export interface NekoEvents {
// connection events // connection events
['connection.status']: (status: 'connected' | 'connecting' | 'disconnected') => void ['connection.status']: (status: 'connected' | 'connecting' | 'disconnected') => void
['connection.type']: (status: 'fallback' | 'webrtc' | 'none') => void
['connection.webrtc.sdp']: (type: 'local' | 'remote', data: string) => void ['connection.webrtc.sdp']: (type: 'local' | 'remote', data: string) => void
['connection.webrtc.sdp.candidate']: (type: 'local' | 'remote', data: RTCIceCandidateInit) => void ['connection.webrtc.sdp.candidate']: (type: 'local' | 'remote', data: RTCIceCandidateInit) => void
['connection.closed']: (error?: Error) => void ['connection.closed']: (error?: Error) => void

View File

@ -489,14 +489,10 @@
} }
} }
@Watch('state.connection.status')
onConnectionChange(status: 'connected' | 'connecting' | 'disconnected') {
this.events.emit('connection.status', status)
}
@Watch('screencast') @Watch('screencast')
onScreencastChange(value: boolean) { @Watch('state.connection.webrtc.connected')
if (value) { updateConnectionType() {
if (this.screencast) {
Vue.set(this.state.connection, 'type', 'fallback') Vue.set(this.state.connection, 'type', 'fallback')
} else if (this.state.connection.webrtc.connected) { } else if (this.state.connection.webrtc.connected) {
Vue.set(this.state.connection, 'type', 'webrtc') Vue.set(this.state.connection, 'type', 'webrtc')
@ -505,6 +501,16 @@
} }
} }
@Watch('state.connection.status')
onConnectionStatusChange(status: 'connected' | 'connecting' | 'disconnected') {
this.events.emit('connection.status', status)
}
@Watch('state.connection.type')
onConnectionTypeChange(type: 'fallback' | 'webrtc' | 'none') {
this.events.emit('connection.type', type)
}
clear() { clear() {
// destroy video // destroy video
if (this._video) { if (this._video) {