1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-26 10:35:59 +01:00

Call onclose on up streams too.

This commit is contained in:
Juliusz Chroboczek 2021-01-12 02:23:22 +01:00
parent 820b303e84
commit 371289793b

View file

@ -236,12 +236,15 @@ ServerConnection.prototype.connect = async function(url) {
}; };
this.socket.onclose = function(e) { this.socket.onclose = function(e) {
sc.permissions = {}; sc.permissions = {};
for(let id in sc.up) {
let c = sc.up[id];
delete(sc.up[id]);
c.close();
}
for(let id in sc.down) { for(let id in sc.down) {
let c = sc.down[id]; let c = sc.down[id];
delete(sc.down[id]); delete(sc.down[id]);
c.close(); c.close();
if(c.onclose)
c.onclose.call(c);
} }
if(sc.group && sc.onjoined) if(sc.group && sc.onjoined)
sc.onjoined.call(sc, 'leave', sc.group, {}, ''); sc.onjoined.call(sc, 'leave', sc.group, {}, '');
@ -528,7 +531,7 @@ ServerConnection.prototype.gotOffer = async function(id, labels, source, usernam
// Unless the server indicates that this is a renegotiation with // Unless the server indicates that this is a renegotiation with
// all parameters unchanged, tear down the existing connection. // all parameters unchanged, tear down the existing connection.
delete(sc.down[id]); delete(sc.down[id]);
c.close(); c.close(true);
c = null; c = null;
} }
@ -634,7 +637,7 @@ ServerConnection.prototype.gotAnswer = async function(id, sdp) {
if(c.onerror) if(c.onerror)
c.onerror.call(c, e); c.onerror.call(c, e);
} finally { } finally {
c.close(); c.close(true);
} }
return; return;
} }
@ -668,8 +671,6 @@ ServerConnection.prototype.gotClose = function(id) {
throw new Error('unknown down stream'); throw new Error('unknown down stream');
delete(this.down[id]); delete(this.down[id]);
c.close(); c.close();
if(c.onclose)
c.onclose.call(c);
}; };
/** /**
@ -882,8 +883,10 @@ function Stream(sc, id, pc, up) {
* For streams in the up direction, this may be called at any time. For * For streams in the up direction, this may be called at any time. For
* streams in the down direction, this will be called automatically when * streams in the down direction, this will be called automatically when
* the server signals that it is closing a stream. * the server signals that it is closing a stream.
*
* @param {boolean} [nocallback]
*/ */
Stream.prototype.close = function() { Stream.prototype.close = function(nocallback) {
let c = this; let c = this;
if(c.statsHandler) { if(c.statsHandler) {
clearInterval(c.statsHandler); clearInterval(c.statsHandler);
@ -909,6 +912,9 @@ Stream.prototype.close = function() {
} catch(e) { } catch(e) {
} }
} }
if(!nocallback && c.onclose)
c.onclose.call(c);
c.sc = null; c.sc = null;
}; };