mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
webrtc connect with selected video.
This commit is contained in:
parent
1d522e30a3
commit
b39022c4de
@ -72,6 +72,7 @@ export class NekoMessages extends EventEmitter<NekoEvents> {
|
||||
this._log.debug('EVENT.SYSTEM_INIT')
|
||||
Vue.set(this._state, 'session_id', conf.session_id)
|
||||
Vue.set(this._state.control, 'implicit_hosting', conf.implicit_hosting)
|
||||
Vue.set(this._state.connection.webrtc, 'videos', conf.webrtc.videos)
|
||||
|
||||
for (const id in conf.sessions) {
|
||||
this[EVENT.SESSION_CREATED](conf.sessions[id])
|
||||
@ -108,10 +109,9 @@ export class NekoMessages extends EventEmitter<NekoEvents> {
|
||||
// Signal Events
|
||||
/////////////////////////////
|
||||
|
||||
protected [EVENT.SIGNAL_PROVIDE]({ event, sdp, video, videos }: message.SignalProvide) {
|
||||
protected [EVENT.SIGNAL_PROVIDE]({ event, sdp, video }: message.SignalProvide) {
|
||||
this._log.debug('EVENT.SIGNAL_PROVIDE')
|
||||
Vue.set(this._state.connection.webrtc, 'video', video)
|
||||
Vue.set(this._state.connection.webrtc, 'videos', videos)
|
||||
// TODO: Handle.
|
||||
this.emit('connection.webrtc.sdp', 'remote', sdp)
|
||||
}
|
||||
|
@ -269,7 +269,7 @@
|
||||
this.websocket.disconnect(new Error('manual action'))
|
||||
}
|
||||
|
||||
public webrtcConnect() {
|
||||
public webrtcConnect(video?: string) {
|
||||
if (!this.connected) {
|
||||
throw new Error('client not connected to websocket')
|
||||
}
|
||||
@ -278,7 +278,11 @@
|
||||
throw new Error('client already connected to webrtc')
|
||||
}
|
||||
|
||||
this.websocket.send(EVENT.SIGNAL_REQUEST)
|
||||
if (video && !this.state.connection.webrtc.videos.includes(video)) {
|
||||
throw new Error('video id not found')
|
||||
}
|
||||
|
||||
this.websocket.send(EVENT.SIGNAL_REQUEST, { video: video })
|
||||
}
|
||||
|
||||
public webrtcDisconnect() {
|
||||
@ -489,6 +493,8 @@
|
||||
|
||||
let webrtcReconnect: any = null
|
||||
this.webrtc.on('disconnected', () => {
|
||||
const lastVideo = this.state.connection.webrtc.video ?? undefined
|
||||
|
||||
this.events.emit('connection.webrtc', 'disconnected')
|
||||
this.clearWebRTCState()
|
||||
|
||||
@ -508,7 +514,7 @@
|
||||
// connect only if disconnected
|
||||
if (this.state.connection.webrtc.status == 'disconnected') {
|
||||
try {
|
||||
this.webrtcConnect()
|
||||
this.webrtcConnect(lastVideo)
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
@ -597,6 +603,7 @@
|
||||
}
|
||||
|
||||
clearWebSocketState() {
|
||||
Vue.set(this.state.connection.webrtc, 'videos', [])
|
||||
Vue.set(this.state.control, 'clipboard', null)
|
||||
Vue.set(this.state.control, 'host_id', null)
|
||||
Vue.set(this.state.control, 'implicit_hosting', false)
|
||||
@ -610,7 +617,6 @@
|
||||
Vue.set(this.state.connection.webrtc, 'status', 'disconnected')
|
||||
Vue.set(this.state.connection.webrtc, 'stats', null)
|
||||
Vue.set(this.state.connection.webrtc, 'video', null)
|
||||
Vue.set(this.state.connection.webrtc, 'videos', [])
|
||||
Vue.set(this.state.connection, 'type', 'none')
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,11 @@ export interface Message {
|
||||
// System
|
||||
/////////////////////////////
|
||||
|
||||
export interface SystemWebRTC {
|
||||
event: string | undefined
|
||||
videos: string[]
|
||||
}
|
||||
|
||||
export interface SystemInit {
|
||||
event: string | undefined
|
||||
session_id: string
|
||||
@ -16,6 +21,7 @@ export interface SystemInit {
|
||||
screen_size: ScreenSize
|
||||
sessions: Record<string, SessionData>
|
||||
implicit_hosting: boolean
|
||||
webrtc: SystemWebRTC
|
||||
}
|
||||
|
||||
export interface SystemAdmin {
|
||||
@ -38,7 +44,6 @@ export interface SignalProvide {
|
||||
sdp: string
|
||||
iceservers: ICEServer[]
|
||||
video: string
|
||||
videos: string[]
|
||||
}
|
||||
|
||||
export interface SignalCandidate extends RTCIceCandidateInit {
|
||||
|
Loading…
Reference in New Issue
Block a user