[verto-communicator] - Added change server feature

When someone set any wss server and do login
VC doesn't record the settings on localStorage,
so when we reload the browser, it will try to connect on
"wss://" + window.location.hostname + ":8082" and if
this wss server is offline for any reason, user will
be stuck on splash screen by auto-login step plus reconnect
modal blocking any action.

- Added button "Change Server" on modal reconnection alert;
- Stop jsonRpcClient retry timeout and delete verto instance
to create a new one when user login with new wss server;
- Record wss server and hostname on localStorage.
This commit is contained in:
StefanYohansson 2016-12-27 11:25:35 -03:00
parent ddf48b8602
commit 10646ab9e3
6 changed files with 29 additions and 11 deletions

View File

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

View File

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

View File

@ -143,6 +143,8 @@
* not connecting prevent two connects
*/
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.email = storage.data.email;
verto.data.login = storage.data.login;

View File

@ -85,6 +85,8 @@
$scope.$apply(function() {
verto.data.connecting = false;
if (connected) {
storage.data.hostname = verto.data.hostname;
storage.data.wsURL = verto.data.wsURL;
storage.data.ui_connected = verto.data.connected;
storage.data.ws_connected = verto.data.connected;
storage.data.name = verto.data.name;
@ -206,10 +208,10 @@
$rootScope.$on('ws.close', onWSClose);
$rootScope.$on('ws.login', onWSLogin);
var ws_modalInstance;
$rootScope.ws_modalInstance;
function onWSClose(ev, data) {
if(ws_modalInstance) {
if($rootScope.ws_modalInstance) {
return;
};
var options = {
@ -217,7 +219,7 @@
keyboard: false
};
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) {
verto.testSpeed();
}
if(!ws_modalInstance) {
if(!$rootScope.ws_modalInstance) {
return;
};
ws_modalInstance.close();
ws_modalInstance = null;
$rootScope.ws_modalInstance.close();
$rootScope.ws_modalInstance = null;
};
$scope.showAbout = function() {

View File

@ -5,10 +5,20 @@
.module('vertoControllers')
.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');
$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
// connecting again.
if (data.instance && !data.instance.rpcClient.socketReady()) {
clearTimeout(data.instance.rpcClient.to);
data.instance.rpcClient.stopRetrying();
data.instance.logout();
data.instance.login();
return;
@ -735,7 +735,6 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
onResCheck: that.refreshVideoResolution
});
}
if (data.mediaPerm) {
ourBootstrap();
} else {