Merge pull request #1126 in FS/freeswitch from ~STEFAN_YOHANSSON/freeswitch:feature/change-wss-server to master

* commit '10646ab9e3f03d1993fd443a48b7b541eb1d6802':
  [verto-communicator] - Added change server feature
This commit is contained in:
Italo Rossi 2016-12-27 16:36:40 -06:00
commit 4e6e860fc8
6 changed files with 29 additions and 11 deletions

View File

@ -359,6 +359,11 @@
return self._ws_socket ? true : false; return self._ws_socket ? true : false;
}; };
$.JsonRpcClient.prototype.stopRetrying = function() {
if (self.to)
clearTimeout(self.to);
}
$.JsonRpcClient.prototype._getSocket = function(onmessage_cb) { $.JsonRpcClient.prototype._getSocket = function(onmessage_cb) {
// If there is no ws url set, we don't have a socket. // If there is no ws url set, we don't have a socket.
// Likewise, if there is no window.WebSocket. // Likewise, if there is no window.WebSocket.

View File

@ -2,7 +2,7 @@
<h3 class="modal-title">Waiting for server reconnection.</h3> <h3 class="modal-title">Waiting for server reconnection.</h3>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<a href="#/login" ng-click="closeReconnect()" class="btn btn-success">Change Server</a>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
</div> </div>

View File

@ -143,6 +143,8 @@
* not connecting prevent two connects * not connecting prevent two connects
*/ */
if (storage.data.ui_connected && storage.data.ws_connected && !verto.data.connecting) { if (storage.data.ui_connected && storage.data.ws_connected && !verto.data.connecting) {
verto.data.hostname = storage.data.hostname || verto.data.hostname;
verto.data.wsURL = storage.data.wsURL || verto.data.wsURL;
verto.data.name = storage.data.name; verto.data.name = storage.data.name;
verto.data.email = storage.data.email; verto.data.email = storage.data.email;
verto.data.login = storage.data.login; verto.data.login = storage.data.login;

View File

@ -85,6 +85,8 @@
$scope.$apply(function() { $scope.$apply(function() {
verto.data.connecting = false; verto.data.connecting = false;
if (connected) { if (connected) {
storage.data.hostname = verto.data.hostname;
storage.data.wsURL = verto.data.wsURL;
storage.data.ui_connected = verto.data.connected; storage.data.ui_connected = verto.data.connected;
storage.data.ws_connected = verto.data.connected; storage.data.ws_connected = verto.data.connected;
storage.data.name = verto.data.name; storage.data.name = verto.data.name;
@ -206,10 +208,10 @@
$rootScope.$on('ws.close', onWSClose); $rootScope.$on('ws.close', onWSClose);
$rootScope.$on('ws.login', onWSLogin); $rootScope.$on('ws.login', onWSLogin);
var ws_modalInstance; $rootScope.ws_modalInstance;
function onWSClose(ev, data) { function onWSClose(ev, data) {
if(ws_modalInstance) { if($rootScope.ws_modalInstance) {
return; return;
}; };
var options = { var options = {
@ -217,7 +219,7 @@
keyboard: false keyboard: false
}; };
if ($scope.showReconnectModal) { if ($scope.showReconnectModal) {
ws_modalInstance = $scope.openModal('partials/ws_reconnect.html', 'ModalWsReconnectController', options); $rootScope.ws_modalInstance = $scope.openModal('partials/ws_reconnect.html', 'ModalWsReconnectController', options);
}; };
}; };
@ -225,12 +227,12 @@
if(storage.data.autoBand) { if(storage.data.autoBand) {
verto.testSpeed(); verto.testSpeed();
} }
if(!ws_modalInstance) { if(!$rootScope.ws_modalInstance) {
return; return;
}; };
ws_modalInstance.close(); $rootScope.ws_modalInstance.close();
ws_modalInstance = null; $rootScope.ws_modalInstance = null;
}; };
$scope.showAbout = function() { $scope.showAbout = function() {

View File

@ -5,10 +5,20 @@
.module('vertoControllers') .module('vertoControllers')
.controller('ModalWsReconnectController', ModalWsReconnectController); .controller('ModalWsReconnectController', ModalWsReconnectController);
ModalWsReconnectController.$inject = ['$scope', 'storage', 'verto']; ModalWsReconnectController.$inject = ['$rootScope', '$scope', 'storage', 'verto'];
function ModalWsReconnectController($scope, storage, verto) { function ModalWsReconnectController($rootScope, $scope, storage, verto) {
console.debug('Executing ModalWsReconnectController'); console.debug('Executing ModalWsReconnectController');
$scope.closeReconnect = closeReconnect;
function closeReconnect() {
if ($rootScope.ws_modalInstance && verto.data.instance) {
verto.data.instance.rpcClient.stopRetrying();
$rootScope.ws_modalInstance.close();
delete verto.data.instance;
}
};
}; };

View File

@ -698,7 +698,7 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
// Checking if we have a failed connection attempt before // Checking if we have a failed connection attempt before
// connecting again. // connecting again.
if (data.instance && !data.instance.rpcClient.socketReady()) { if (data.instance && !data.instance.rpcClient.socketReady()) {
clearTimeout(data.instance.rpcClient.to); data.instance.rpcClient.stopRetrying();
data.instance.logout(); data.instance.logout();
data.instance.login(); data.instance.login();
return; return;
@ -735,7 +735,6 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
onResCheck: that.refreshVideoResolution onResCheck: that.refreshVideoResolution
}); });
} }
if (data.mediaPerm) { if (data.mediaPerm) {
ourBootstrap(); ourBootstrap();
} else { } else {