From 6312ae2cd2f5200994354f675925048b9d721fc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Sun, 18 Apr 2021 22:49:41 +0200 Subject: [PATCH] forward webrtc sdp for debugging, #15. --- src/component/internal/messages.ts | 6 +++++- src/component/main.vue | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/component/internal/messages.ts b/src/component/internal/messages.ts index daf4c97e..85a8b374 100644 --- a/src/component/internal/messages.ts +++ b/src/component/internal/messages.ts @@ -11,6 +11,8 @@ export interface NekoEvents { // connection events ['connection.websocket']: (state: 'connected' | 'connecting' | 'disconnected') => void ['connection.webrtc']: (state: 'connected' | 'connecting' | 'disconnected') => void + ['connection.webrtc.sdp']: (type: 'local' | 'remote', data: string) => void + ['connection.webrtc.sdp.candidate']: (type: 'local' | 'remote', data: RTCIceCandidateInit) => void ['connection.disconnect']: (message: string) => void // drag and drop events @@ -106,16 +108,18 @@ export class NekoMessages extends EventEmitter { // Signal Events ///////////////////////////// - protected [EVENT.SIGNAL_PROVIDE]({ event, video, videos }: message.SignalProvide) { + protected [EVENT.SIGNAL_PROVIDE]({ event, sdp, video, videos }: 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) } protected [EVENT.SIGNAL_CANDIDATE]({ event, ...candidate }: message.SignalCandidate) { this._log.debug('EVENT.SIGNAL_CANDIDATE') // TODO: Handle. + this.emit('connection.webrtc.sdp.candidate', 'remote', candidate) } protected [EVENT.SIGNAL_VIDEO]({ event, video }: message.SignalVideo) { diff --git a/src/component/main.vue b/src/component/main.vue index 5d6ea5fe..8ba09891 100644 --- a/src/component/main.vue +++ b/src/component/main.vue @@ -369,6 +369,7 @@ try { let sdp = await this.webrtc.connect(payload.sdp, payload.iceservers) this.websocket.send(EVENT.SIGNAL_ANSWER, { sdp }) + this.events.emit('connection.webrtc.sdp', 'local', sdp) } catch (e) {} break case EVENT.SIGNAL_CANDIDATE: @@ -417,6 +418,7 @@ }) this.webrtc.on('candidate', (candidate: RTCIceCandidateInit) => { this.websocket.send(EVENT.SIGNAL_CANDIDATE, candidate) + this.events.emit('connection.webrtc.sdp.candidate', 'local', candidate) }) let webrtcCongestion: number = 0