add signal close.

This commit is contained in:
Miroslav Šedivý 2022-02-12 14:19:48 +01:00
parent a482267839
commit 1fdcac5826
3 changed files with 14 additions and 0 deletions

View File

@ -191,6 +191,11 @@ export class NekoMessages extends EventEmitter<NekoEvents> {
Vue.set(this._state.connection.webrtc, 'video', video) Vue.set(this._state.connection.webrtc, 'video', video)
} }
protected [EVENT.SIGNAL_CLOSE]() {
this._localLog.debug(`EVENT.SIGNAL_CLOSE`)
this._connection.webrtc.close()
}
///////////////////////////// /////////////////////////////
// Session Events // Session Events
///////////////////////////// /////////////////////////////

View File

@ -230,6 +230,14 @@ export class NekoWebRTC extends EventEmitter<NekoWebRTCEvents> {
await this._peer.setRemoteDescription({ type: 'answer', sdp }) await this._peer.setRemoteDescription({ type: 'answer', sdp })
} }
public async close() {
if (!this._peer) {
throw new Error('attempting to close nonexistent peer')
}
this._peer.close()
}
public addTrack(track: MediaStreamTrack, ...streams: MediaStream[]): RTCRtpSender { public addTrack(track: MediaStreamTrack, ...streams: MediaStream[]): RTCRtpSender {
if (!this._peer) { if (!this._peer) {
throw new Error('attempting to add track for nonexistent peer') throw new Error('attempting to add track for nonexistent peer')

View File

@ -10,6 +10,7 @@ export const SIGNAL_ANSWER = 'signal/answer'
export const SIGNAL_PROVIDE = 'signal/provide' export const SIGNAL_PROVIDE = 'signal/provide'
export const SIGNAL_CANDIDATE = 'signal/candidate' export const SIGNAL_CANDIDATE = 'signal/candidate'
export const SIGNAL_VIDEO = 'signal/video' export const SIGNAL_VIDEO = 'signal/video'
export const SIGNAL_CLOSE = 'signal/close'
export const SESSION_CREATED = 'session/created' export const SESSION_CREATED = 'session/created'
export const SESSION_DELETED = 'session/deleted' export const SESSION_DELETED = 'session/deleted'