Skip to content

Commit c28101a

Browse files
committed
No longer disconnect ongoing calls on websocket disconnnect or error. Instead resurrect state when id still is the same on successfull reconnect.
1 parent f535724 commit c28101a

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

static/js/controllers/mediastreamcontroller.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,9 @@ define(['underscore', 'bigscreen', 'moment', 'webrtc.adapter'], function(_, BigS
154154
}
155155
};
156156

157-
// Cache.
157+
// Data voids.
158158
var cache = {};
159+
var resurrect = null;
159160

160161
$scope.update = function(user, noRefresh) {
161162
$scope.master = angular.copy(user);
@@ -171,6 +172,10 @@ define(['underscore', 'bigscreen', 'moment', 'webrtc.adapter'], function(_, BigS
171172
$scope.$emit("status", status);
172173
};
173174

175+
$scope.getStatus = function() {
176+
return $scope.status;
177+
};
178+
174179
$scope.updateStatus = (function() {
175180
return function() {
176181
// This is the user status.
@@ -387,9 +392,22 @@ define(['underscore', 'bigscreen', 'moment', 'webrtc.adapter'], function(_, BigS
387392
mediaStream.api.sendSelf();
388393
}, data.Turn.ttl / 100 * 90 * 1000);
389394
}
395+
// Support resurrection shrine.
396+
if (resurrect) {
397+
var resurrection = resurrect;
398+
resurrect = null;
399+
$timeout(function() {
400+
if (resurrection.id === $scope.id) {
401+
console.log("Using resurrection shrine", resurrection);
402+
// Valid resurrection.
403+
$scope.setStatus(resurrection.status);
404+
}
405+
}, 0);
406+
}
390407
});
391408

392409
mediaStream.webrtc.e.on("peercall", function(event, peercall) {
410+
393411
// Kill timeout.
394412
$timeout.cancel(pickupTimeout);
395413
pickupTimeout = null;
@@ -466,6 +484,14 @@ define(['underscore', 'bigscreen', 'moment', 'webrtc.adapter'], function(_, BigS
466484

467485
var reconnect = function() {
468486
if (connected && autoreconnect) {
487+
if (resurrect == null) {
488+
// Storage data at the resurrection shrine.
489+
resurrect = {
490+
status: $scope.getStatus(),
491+
id: $scope.id
492+
}
493+
console.log("Stored data at the resurrection shrine", resurrect);
494+
}
469495
reconnecting = false;
470496
_.delay(function() {
471497
if (autoreconnect && !reconnecting) {

static/js/services/mediastream.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,6 @@ define([
8181
$rootScope.roomlink = null;
8282
$rootScope.roomstatus = false;
8383

84-
connector.e.on("closed error", _.bind(function(event, options) {
85-
var opts = $.extend({}, options);
86-
if (!opts.soft) {
87-
// Do not hang up when this is a soft event.
88-
webrtc.doHangup();
89-
}
90-
}, this));
91-
9284
var connect = function() {
9385
if (ready && cont) {
9486
// Inject connector function into scope, so that controllers can pick it up.

0 commit comments

Comments
 (0)