mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
webrtc connect / disconnect functions.
This commit is contained in:
parent
f30614db25
commit
cab53d7d17
@ -73,11 +73,14 @@ export class NekoWebRTC extends EventEmitter<NekoWebRTCEvents> {
|
||||
this._log.debug(`peer ice connection state changed: ${this._peer!.iceConnectionState}`)
|
||||
|
||||
switch (this._state) {
|
||||
case 'disconnected':
|
||||
this.onDisconnected(new Error('peer disconnected'))
|
||||
break
|
||||
case 'failed':
|
||||
this.onDisconnected(new Error('peer failed'))
|
||||
break
|
||||
case 'disconnected':
|
||||
this.onDisconnected(new Error('peer disconnected'))
|
||||
case 'closed':
|
||||
this.onDisconnected(new Error('peer closed'))
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
:webrtc="webrtc"
|
||||
:screenWidth="state.screen.size.width"
|
||||
:screenHeight="state.screen.size.height"
|
||||
:isControling="controlling"
|
||||
:isControling="controlling && watching"
|
||||
:scrollSensitivity="state.control.scroll.sensitivity"
|
||||
:scrollInvert="state.control.scroll.inverse"
|
||||
:implicitControl="state.control.implicit_hosting && state.members[state.member_id].profile.can_host"
|
||||
@ -113,7 +113,11 @@
|
||||
} as NekoState
|
||||
|
||||
public get connected() {
|
||||
return this.state.connection.websocket == 'connected' && this.state.connection.webrtc == 'connected'
|
||||
return this.state.connection.websocket == 'connected'
|
||||
}
|
||||
|
||||
public get watching() {
|
||||
return this.state.connection.webrtc == 'connected'
|
||||
}
|
||||
|
||||
public get controlling() {
|
||||
@ -153,6 +157,30 @@
|
||||
this.api.disconnect()
|
||||
}
|
||||
|
||||
public webrtcConnect() {
|
||||
if (!this.connected) {
|
||||
throw new Error('client not connected to websocket')
|
||||
}
|
||||
|
||||
if (this.watching) {
|
||||
throw new Error('client already connected to webrtc')
|
||||
}
|
||||
|
||||
this.websocket.send('signal/request')
|
||||
}
|
||||
|
||||
public webrtcDisconnect() {
|
||||
if (!this.connected) {
|
||||
throw new Error('client not connected to websocket')
|
||||
}
|
||||
|
||||
if (!this.watching) {
|
||||
throw new Error('client not connected to webrtc')
|
||||
}
|
||||
|
||||
this.webrtc.disconnect()
|
||||
}
|
||||
|
||||
public play() {
|
||||
this._video.play()
|
||||
}
|
||||
@ -290,9 +318,9 @@
|
||||
this.events.emit('internal.websocket', 'connecting')
|
||||
})
|
||||
this.websocket.on('connected', () => {
|
||||
this.websocket.send('signal/request')
|
||||
Vue.set(this.state.connection, 'websocket', 'connected')
|
||||
this.events.emit('internal.websocket', 'connected')
|
||||
this.webrtcConnect()
|
||||
})
|
||||
this.websocket.on('disconnected', () => {
|
||||
Vue.set(this.state.connection, 'websocket', 'disconnected')
|
||||
|
Loading…
Reference in New Issue
Block a user