mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
single connection status in state.
This commit is contained in:
parent
a451d6a536
commit
1dcce7d949
@ -28,29 +28,48 @@ export class NekoConnection extends EventEmitter<NekoConnectionEvents> {
|
|||||||
|
|
||||||
// initial state
|
// initial state
|
||||||
Vue.set(this._state, 'type', 'webrtc')
|
Vue.set(this._state, 'type', 'webrtc')
|
||||||
Vue.set(this._state, 'websocket', this.websocket.supported ? 'disconnected' : 'unavailable')
|
|
||||||
Vue.set(this._state.webrtc, 'status', this.webrtc.supported ? 'disconnected' : 'unavailable')
|
let webSocketStatus = 'disconnected'
|
||||||
|
let webRTCStatus = 'disconnected'
|
||||||
|
|
||||||
// websocket
|
// websocket
|
||||||
this.websocket.on('connecting', () => {
|
this.websocket.on('connecting', () => {
|
||||||
Vue.set(this._state, 'websocket', 'connecting')
|
webSocketStatus = 'connecting'
|
||||||
|
if (this._state.status !== 'connecting') {
|
||||||
|
Vue.set(this._state, 'status', 'connecting')
|
||||||
|
}
|
||||||
})
|
})
|
||||||
this.websocket.on('connected', () => {
|
this.websocket.on('connected', () => {
|
||||||
Vue.set(this._state, 'websocket', 'connected')
|
webSocketStatus = 'connected'
|
||||||
|
if (webSocketStatus == 'connected' && webRTCStatus == 'connected') {
|
||||||
|
Vue.set(this._state, 'status', 'connected')
|
||||||
|
}
|
||||||
})
|
})
|
||||||
this.websocket.on('disconnected', () => {
|
this.websocket.on('disconnected', () => {
|
||||||
Vue.set(this._state, 'websocket', 'disconnected')
|
webSocketStatus = 'disconnected'
|
||||||
|
if (this._state.status !== 'disconnected') {
|
||||||
|
Vue.set(this._state, 'status', 'disconnected')
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// webrtc
|
// webrtc
|
||||||
this.webrtc.on('connecting', () => {
|
this.webrtc.on('connecting', () => {
|
||||||
Vue.set(this._state.webrtc, 'status', 'connecting')
|
webRTCStatus = 'connecting'
|
||||||
|
if (this._state.status !== 'connecting') {
|
||||||
|
Vue.set(this._state, 'status', 'connecting')
|
||||||
|
}
|
||||||
})
|
})
|
||||||
this.webrtc.on('connected', () => {
|
this.webrtc.on('connected', () => {
|
||||||
Vue.set(this._state.webrtc, 'status', 'connected')
|
webRTCStatus = 'connected'
|
||||||
|
if (webSocketStatus == 'connected' && webRTCStatus == 'connected') {
|
||||||
|
Vue.set(this._state, 'status', 'connected')
|
||||||
|
}
|
||||||
})
|
})
|
||||||
this.webrtc.on('disconnected', () => {
|
this.webrtc.on('disconnected', () => {
|
||||||
Vue.set(this._state.webrtc, 'status', 'disconnected')
|
webRTCStatus = 'disconnected'
|
||||||
|
if (this._state.status !== 'disconnected') {
|
||||||
|
Vue.set(this._state, 'status', 'disconnected')
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,5 +95,6 @@ export class NekoConnection extends EventEmitter<NekoConnectionEvents> {
|
|||||||
|
|
||||||
public disconnect() {
|
public disconnect() {
|
||||||
this.websocket.disconnect()
|
this.websocket.disconnect()
|
||||||
|
Vue.set(this._state, 'status', 'disconnected')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
:scroll="state.control.scroll"
|
:scroll="state.control.scroll"
|
||||||
:screenSize="state.screen.size"
|
:screenSize="state.screen.size"
|
||||||
:canvasSize="canvasSize"
|
:canvasSize="canvasSize"
|
||||||
:isControling="controlling && watching"
|
:isControling="controlling"
|
||||||
:cursorTag="
|
:cursorTag="
|
||||||
state.control.implicit_hosting && state.control.host_id != null
|
state.control.implicit_hosting && state.control.host_id != null
|
||||||
? state.sessions[state.control.host_id].profile.name
|
? state.sessions[state.control.host_id].profile.name
|
||||||
@ -101,9 +101,8 @@
|
|||||||
public state = {
|
public state = {
|
||||||
authenticated: false,
|
authenticated: false,
|
||||||
connection: {
|
connection: {
|
||||||
websocket: 'disconnected',
|
|
||||||
webrtc: {
|
|
||||||
status: 'disconnected',
|
status: 'disconnected',
|
||||||
|
webrtc: {
|
||||||
stats: null,
|
stats: null,
|
||||||
video: null,
|
video: null,
|
||||||
videos: [],
|
videos: [],
|
||||||
@ -148,11 +147,7 @@
|
|||||||
public connection = new NekoConnection(this.state.connection)
|
public connection = new NekoConnection(this.state.connection)
|
||||||
|
|
||||||
public get connected() {
|
public get connected() {
|
||||||
return this.state.connection.websocket == 'connected'
|
return this.state.connection.status == 'connected'
|
||||||
}
|
|
||||||
|
|
||||||
public get watching() {
|
|
||||||
return this.state.connection.webrtc.status == 'connected'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public get controlling() {
|
public get controlling() {
|
||||||
@ -516,7 +511,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// websocket
|
// websocket
|
||||||
Vue.set(this.state.connection, 'websocket', 'disconnected')
|
|
||||||
Vue.set(this.state.connection.webrtc, 'videos', [])
|
Vue.set(this.state.connection.webrtc, 'videos', [])
|
||||||
Vue.set(this.state.control, 'clipboard', null)
|
Vue.set(this.state.control, 'clipboard', null)
|
||||||
Vue.set(this.state.control, 'host_id', null)
|
Vue.set(this.state.control, 'host_id', null)
|
||||||
@ -527,7 +521,6 @@
|
|||||||
Vue.set(this.state, 'sessions', {})
|
Vue.set(this.state, 'sessions', {})
|
||||||
|
|
||||||
// webrtc
|
// webrtc
|
||||||
Vue.set(this.state.connection.webrtc, 'status', 'disconnected')
|
|
||||||
Vue.set(this.state.connection.webrtc, 'stats', null)
|
Vue.set(this.state.connection.webrtc, 'stats', null)
|
||||||
Vue.set(this.state.connection.webrtc, 'video', null)
|
Vue.set(this.state.connection.webrtc, 'video', null)
|
||||||
Vue.set(this.state.connection, 'type', 'none')
|
Vue.set(this.state.connection, 'type', 'none')
|
||||||
|
@ -13,13 +13,12 @@ export default interface State {
|
|||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
|
|
||||||
export interface Connection {
|
export interface Connection {
|
||||||
websocket: 'unavailable' | 'disconnected' | 'connecting' | 'connected'
|
status: 'disconnected' | 'connecting' | 'connected'
|
||||||
webrtc: WebRTC
|
webrtc: WebRTC
|
||||||
type: 'webrtc' | 'fallback' | 'none'
|
type: 'webrtc' | 'fallback' | 'none'
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WebRTC {
|
export interface WebRTC {
|
||||||
status: 'unavailable' | 'disconnected' | 'connecting' | 'connected'
|
|
||||||
stats: WebRTCStats | null
|
stats: WebRTCStats | null
|
||||||
video: string | null
|
video: string | null
|
||||||
videos: string[]
|
videos: string[]
|
||||||
|
Loading…
Reference in New Issue
Block a user