Browse Source

No longer disconnect ongoing calls on websocket disconnnect or error. Instead resurrect state when id still is the same on successfull reconnect.

pull/18/head
Simon Eisenmann 11 years ago
parent
commit
c28101a730
  1. 28
      static/js/controllers/mediastreamcontroller.js
  2. 8
      static/js/services/mediastream.js

28
static/js/controllers/mediastreamcontroller.js

@ -154,8 +154,9 @@ define(['underscore', 'bigscreen', 'moment', 'webrtc.adapter'], function(_, BigS @@ -154,8 +154,9 @@ define(['underscore', 'bigscreen', 'moment', 'webrtc.adapter'], function(_, BigS
}
};
// Cache.
// Data voids.
var cache = {};
var resurrect = null;
$scope.update = function(user, noRefresh) {
$scope.master = angular.copy(user);
@ -171,6 +172,10 @@ define(['underscore', 'bigscreen', 'moment', 'webrtc.adapter'], function(_, BigS @@ -171,6 +172,10 @@ define(['underscore', 'bigscreen', 'moment', 'webrtc.adapter'], function(_, BigS
$scope.$emit("status", status);
};
$scope.getStatus = function() {
return $scope.status;
};
$scope.updateStatus = (function() {
return function() {
// This is the user status.
@ -387,9 +392,22 @@ define(['underscore', 'bigscreen', 'moment', 'webrtc.adapter'], function(_, BigS @@ -387,9 +392,22 @@ define(['underscore', 'bigscreen', 'moment', 'webrtc.adapter'], function(_, BigS
mediaStream.api.sendSelf();
}, data.Turn.ttl / 100 * 90 * 1000);
}
// Support resurrection shrine.
if (resurrect) {
var resurrection = resurrect;
resurrect = null;
$timeout(function() {
if (resurrection.id === $scope.id) {
console.log("Using resurrection shrine", resurrection);
// Valid resurrection.
$scope.setStatus(resurrection.status);
}
}, 0);
}
});
mediaStream.webrtc.e.on("peercall", function(event, peercall) {
// Kill timeout.
$timeout.cancel(pickupTimeout);
pickupTimeout = null;
@ -466,6 +484,14 @@ define(['underscore', 'bigscreen', 'moment', 'webrtc.adapter'], function(_, BigS @@ -466,6 +484,14 @@ define(['underscore', 'bigscreen', 'moment', 'webrtc.adapter'], function(_, BigS
var reconnect = function() {
if (connected && autoreconnect) {
if (resurrect == null) {
// Storage data at the resurrection shrine.
resurrect = {
status: $scope.getStatus(),
id: $scope.id
}
console.log("Stored data at the resurrection shrine", resurrect);
}
reconnecting = false;
_.delay(function() {
if (autoreconnect && !reconnecting) {

8
static/js/services/mediastream.js

@ -81,14 +81,6 @@ define([ @@ -81,14 +81,6 @@ define([
$rootScope.roomlink = null;
$rootScope.roomstatus = false;
connector.e.on("closed error", _.bind(function(event, options) {
var opts = $.extend({}, options);
if (!opts.soft) {
// Do not hang up when this is a soft event.
webrtc.doHangup();
}
}, this));
var connect = function() {
if (ready && cont) {
// Inject connector function into scope, so that controllers can pick it up.

Loading…
Cancel
Save