mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1076794 Make Loop calls handle networkDisconnected events properly so that the correct messages get displayed. r=Standard8
This commit is contained in:
parent
aba9c3da0c
commit
c0ae909548
@ -177,8 +177,6 @@ loop.shared.models = (function(l10n) {
|
||||
this._connectionDestroyed);
|
||||
this.listenTo(this.session, "sessionDisconnected",
|
||||
this._sessionDisconnected);
|
||||
this.listenTo(this.session, "networkDisconnected",
|
||||
this._networkDisconnected);
|
||||
this.session.connect(this.get("apiKey"), this.get("sessionToken"),
|
||||
this._onConnectCompletion.bind(this));
|
||||
},
|
||||
@ -323,9 +321,17 @@ loop.shared.models = (function(l10n) {
|
||||
* @param {SessionDisconnectEvent} event
|
||||
*/
|
||||
_sessionDisconnected: function(event) {
|
||||
if(event.reason === "networkDisconnected") {
|
||||
this._signalEnd("session:network-disconnected", event);
|
||||
} else {
|
||||
this._signalEnd("session:ended", event);
|
||||
}
|
||||
},
|
||||
|
||||
_signalEnd: function(eventName, event) {
|
||||
this.set("connected", false)
|
||||
.set("ongoing", false)
|
||||
.trigger("session:ended");
|
||||
.trigger(eventName, event);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -335,24 +341,11 @@ loop.shared.models = (function(l10n) {
|
||||
* @param {ConnectionEvent} event
|
||||
*/
|
||||
_connectionDestroyed: function(event) {
|
||||
this.set("connected", false)
|
||||
.set("ongoing", false)
|
||||
.trigger("session:peer-hungup", {
|
||||
connectionId: event.connection.connectionId
|
||||
});
|
||||
this.endSession();
|
||||
},
|
||||
|
||||
/**
|
||||
* Network was disconnected.
|
||||
* http://tokbox.com/opentok/libraries/client/js/reference/ConnectionEvent.html
|
||||
*
|
||||
* @param {ConnectionEvent} event
|
||||
*/
|
||||
_networkDisconnected: function(event) {
|
||||
this.set("connected", false)
|
||||
.set("ongoing", false)
|
||||
.trigger("session:network-disconnected");
|
||||
if (event.reason === "networkDisconnected") {
|
||||
this._signalEnd("session:network-disconnected", event);
|
||||
} else {
|
||||
this._signalEnd("session:peer-hungup", event);
|
||||
}
|
||||
this.endSession();
|
||||
},
|
||||
});
|
||||
|
@ -253,6 +253,20 @@ describe("loop.shared.models", function() {
|
||||
fakeSession.trigger("sessionDisconnected", {reason: "ko"});
|
||||
});
|
||||
|
||||
it("should trigger network-disconnected on networkDisconnect reason",
|
||||
function(done) {
|
||||
model.once("session:network-disconnected", function() {
|
||||
done();
|
||||
});
|
||||
|
||||
var fakeEvent = {
|
||||
connectionId: 42,
|
||||
reason: "networkDisconnected"
|
||||
};
|
||||
|
||||
fakeSession.trigger("sessionDisconnected", fakeEvent);
|
||||
});
|
||||
|
||||
it("should set the connected attribute to false on sessionDisconnected",
|
||||
function() {
|
||||
fakeSession.trigger("sessionDisconnected", {reason: "ko"});
|
||||
@ -273,7 +287,7 @@ describe("loop.shared.models", function() {
|
||||
it("should trigger a session:peer-hungup model event",
|
||||
function(done) {
|
||||
model.once("session:peer-hungup", function(event) {
|
||||
expect(event.connectionId).eql(42);
|
||||
expect(event.connection.connectionId).eql(42);
|
||||
done();
|
||||
});
|
||||
|
||||
@ -288,25 +302,6 @@ describe("loop.shared.models", function() {
|
||||
sinon.assert.calledOnce(model.endSession);
|
||||
});
|
||||
});
|
||||
|
||||
describe("networkDisconnected event received", function() {
|
||||
it("should trigger a session:network-disconnected event",
|
||||
function(done) {
|
||||
model.once("session:network-disconnected", function() {
|
||||
done();
|
||||
});
|
||||
|
||||
fakeSession.trigger("networkDisconnected");
|
||||
});
|
||||
|
||||
it("should terminate the session", function() {
|
||||
sandbox.stub(model, "endSession");
|
||||
|
||||
fakeSession.trigger("networkDisconnected", {reason: "ko"});
|
||||
|
||||
sinon.assert.calledOnce(model.endSession);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user