From dbf9a935d4a7f0cf3ef17754ce98efa5f8829139 Mon Sep 17 00:00:00 2001 From: Simon Eisenmann Date: Fri, 11 Apr 2014 15:52:52 +0200 Subject: [PATCH] Avoid spurious bye and close events and fixed hangup in certain conference cases. --- static/js/mediastream/peercall.js | 4 ++++ static/js/mediastream/webrtc.js | 18 +++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/static/js/mediastream/peercall.js b/static/js/mediastream/peercall.js index 347fcb51..335458e6 100644 --- a/static/js/mediastream/peercall.js +++ b/static/js/mediastream/peercall.js @@ -271,6 +271,10 @@ define(['jquery', 'underscore', 'mediastream/utils', 'mediastream/peerconnection PeerCall.prototype.close = function() { + if (this.closed) { + return; + } + this.closed = true; _.each(this.datachannels, function(datachannel) { diff --git a/static/js/mediastream/webrtc.js b/static/js/mediastream/webrtc.js index 0817cf84..ad61f64f 100644 --- a/static/js/mediastream/webrtc.js +++ b/static/js/mediastream/webrtc.js @@ -152,7 +152,7 @@ define([ return; } console.log("Bye process (started false)"); - this.doHangup(); + this.doHangup("receivedbye", from); break; default: this.msgQueue.push([to, data, type, to2, from]); @@ -177,6 +177,10 @@ define([ targetcall = this.currentcall; break; } + if (this.currentcall.id === id) { + targetcall = this.currentcall; + break; + } if (this.currentconference) { targetcall = this.currentconference.getCall(id) } @@ -280,16 +284,16 @@ define([ if (newcurrentcall) { this.currentcall = newcurrentcall; targetcall.close() - this.api.sendBye(targetcall.id, null); + //this.api.sendBye(targetcall.id, null); this.e.triggerHandler("peercall", [newcurrentcall]); this.e.triggerHandler("peerconference", [this.currentconference]); } else { - this.doHangup(); + this.doHangup("receivedbye", targetcall.id); this.e.triggerHandler("bye", [data.Reason, from, to, to2]); } } else { targetcall.close(); - this.api.sendBye(targetcall.id, null); + //this.api.sendBye(targetcall.id, null); } break; case "Conference": @@ -570,7 +574,9 @@ define([ } if (currentcall !== this.currentcall) { currentcall.close(); - this.api.sendBye(id, reason); + if (reason !== "receivedbye") { + this.api.sendBye(id, reason); + } if (this.currentcall && currentcall) { this.e.triggerHandler("statechange", ["connected", this.currentcall]); } else { @@ -585,7 +591,9 @@ define([ } this.stop(); if (id) { + if (reason !== "receivedbye") { this.api.sendBye(id, reason); + } } }