1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-23 00:55:58 +01:00

Improve error handling during negotiation.

This commit is contained in:
Juliusz Chroboczek 2020-12-25 18:26:30 +01:00
parent d5c7a13aae
commit e3fd9a963a

View file

@ -620,17 +620,30 @@ ServerConnection.prototype.gotOffer = async function(id, labels, offer, renegoti
if(sc.ondownstream) if(sc.ondownstream)
sc.ondownstream.call(sc, c); sc.ondownstream.call(sc, c);
await c.pc.setRemoteDescription(offer); try {
await c.flushRemoteIceCandidates() await c.pc.setRemoteDescription(offer);
let answer = await c.pc.createAnswer();
if(!answer) await c.flushRemoteIceCandidates();
throw new Error("Didn't create answer");
await c.pc.setLocalDescription(answer); let answer = await c.pc.createAnswer();
this.send({ if(!answer)
type: 'answer', throw new Error("Didn't create answer");
id: id, await c.pc.setLocalDescription(answer);
answer: answer, this.send({
}); type: 'answer',
id: id,
answer: answer,
});
} catch(e) {
try {
if(c.onerror)
c.onerror.call(c, e);
} finally {
c.abort();
}
return;
}
c.localDescriptionSent = true; c.localDescriptionSent = true;
c.flushLocalIceCandidates(); c.flushLocalIceCandidates();
if(c.onnegotiationcompleted) if(c.onnegotiationcompleted)
@ -667,8 +680,12 @@ ServerConnection.prototype.gotAnswer = async function(id, answer) {
try { try {
await c.pc.setRemoteDescription(answer); await c.pc.setRemoteDescription(answer);
} catch(e) { } catch(e) {
if(c.onerror) try {
c.onerror.call(c, e); if(c.onerror)
c.onerror.call(c, e);
} finally {
c.close();
}
return; return;
} }
await c.flushRemoteIceCandidates(); await c.flushRemoteIceCandidates();