mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
accept candidates before offer.
This commit is contained in:
parent
4850b5cb7c
commit
b0ed563792
@ -41,9 +41,10 @@ export class NekoWebRTC extends EventEmitter<NekoWebRTCEvents> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
candidates: RTCIceCandidateInit[] = []
|
||||||
public async setCandidate(candidate: RTCIceCandidateInit) {
|
public async setCandidate(candidate: RTCIceCandidateInit) {
|
||||||
if (!this._peer) {
|
if (!this._peer) {
|
||||||
this._log.warn(`could not add remote ICE candidate: peer does not exist!`)
|
this.candidates.push(candidate)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,6 +72,15 @@ export class NekoWebRTC extends EventEmitter<NekoWebRTCEvents> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.candidates.length > 0) {
|
||||||
|
for (const candidate of this.candidates) {
|
||||||
|
this._peer.addIceCandidate(candidate)
|
||||||
|
}
|
||||||
|
|
||||||
|
this._log.debug(`added ${this.candidates.length} remote ICE candidates`, this.candidates)
|
||||||
|
this.candidates = []
|
||||||
|
}
|
||||||
|
|
||||||
this._peer.onconnectionstatechange = (event) => {
|
this._peer.onconnectionstatechange = (event) => {
|
||||||
this._log.debug(`peer connection state changed`, this._peer ? this._peer.connectionState : undefined)
|
this._log.debug(`peer connection state changed`, this._peer ? this._peer.connectionState : undefined)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user