Bug 1207575 - Fix reporting of Loop's connection status if a user exits a room and then re-enters it without reloading the room. r=Mardak

This commit is contained in:
Mark Banner 2015-09-25 18:55:53 +01:00
parent 797714b196
commit d704ed62b2
2 changed files with 45 additions and 6 deletions

View File

@ -38,13 +38,9 @@ loop.OTSdkDriver = (function() {
this.connections = {};
// Metrics object to keep track of the number of connections we have
// Setup the metrics object to keep track of the number of connections we have
// and the amount of streams.
this._metrics = {
connections: 0,
sendStreams: 0,
recvStreams: 0
};
this._resetMetrics();
this.dispatcher.register(this, [
"setupStreamElements",
@ -108,6 +104,17 @@ loop.OTSdkDriver = (function() {
};
},
/**
* Resets the metrics for the driver.
*/
_resetMetrics: function() {
this._metrics = {
connections: 0,
sendStreams: 0,
recvStreams: 0
};
},
/**
* Handles the setupStreamElements action. Saves the required data and
* kicks off the initialising of the publisher.
@ -293,6 +300,9 @@ loop.OTSdkDriver = (function() {
delete this.publisher;
}
// Now reset the metrics as well.
this._resetMetrics();
this._noteConnectionLengthIfNeeded(this._getTwoWayMediaStartTime(), performance.now());
// Also, tidy these variables ready for next time.

View File

@ -113,6 +113,19 @@ describe("loop.OTSdkDriver", function () {
new loop.OTSdkDriver({dispatcher: dispatcher});
}).to.Throw(/sdk/);
});
it("should set the metrics to zero", function() {
driver = new loop.OTSdkDriver({
dispatcher: dispatcher,
sdk: sdk
});
expect(driver._metrics).eql({
connections: 0,
sendStreams: 0,
recvStreams: 0
});
});
});
describe("#setupStreamElements", function() {
@ -474,6 +487,22 @@ describe("loop.OTSdkDriver", function () {
expect(subscribedEvents).eql([]);
});
it("should reset the metrics to zero", function() {
driver._metrics = {
connections: 1,
sendStreams: 2,
recvStreams: 3
};
driver.disconnectSession();
expect(driver._metrics).eql({
connections: 0,
sendStreams: 0,
recvStreams: 0
});
});
it("should dispatch a DataChannelsAvailable action with available = false", function() {
driver.disconnectSession();