GUAC-605: Make guacClient status/error events more consistent. Add "reconnect" callback to ALL error events.

This commit is contained in:
Michael Jumper
2014-11-12 20:02:25 -08:00
parent 53411640a0
commit 3f55c93bc4

View File

@@ -192,25 +192,25 @@ angular.module('client').directive('guacClient', [function guacClient() {
// Idle // Idle
case 0: case 0:
$scope.$emit('guacClientStatusChange', guac, "idle"); $scope.$emit('guacClientStateChange', guac, "idle");
break; break;
// Connecting // Connecting
case 1: case 1:
$scope.$emit('guacClientStatusChange', guac, "connecting"); $scope.$emit('guacClientStateChange', guac, "connecting");
break; break;
// Connected + waiting // Connected + waiting
case 2: case 2:
$scope.$emit('guacClientStatusChange', guac, "waiting"); $scope.$emit('guacClientStateChange', guac, "waiting");
break; break;
// Connected // Connected
case 3: case 3:
$scope.$emit('guacClientStatusChange', guac, "connected"); $scope.$emit('guacClientStateChange', guac, "connected");
// Update server clipboard with current data // Update server clipboard with current data
var clipboard = localStorageUtility.get("clipboard"); var clipboard = localStorageUtility.get("clipboard");
@@ -224,9 +224,6 @@ angular.module('client').directive('guacClient', [function guacClient() {
case 5: case 5:
break; break;
// Unknown status code
default:
$scope.$emit('guacClientError', guac, "unknown");
} }
}; };
@@ -252,9 +249,7 @@ angular.module('client').directive('guacClient', [function guacClient() {
// Disconnect, if connected // Disconnect, if connected
guac.disconnect(); guac.disconnect();
$scope.$emit('guacClientError', guac, status.code, {operations: {reconnect: function reconnect () { $scope.$emit('guacClientError', guac, status.code, $scope.connect);
$scope.connect();
}}});
}; };
@@ -525,19 +520,31 @@ angular.module('client').directive('guacClient', [function guacClient() {
}); });
// Show connection errors from tunnel // Fire events for tunnel errors
$scope.tunnel.onerror = function onerror(status) { $scope.tunnel.onerror = function onerror(status) {
$scope.$emit('guacTunnelError', $scope.guac, status.code, $scope.connect);
//FIXME: Needs to auto reconnect - should that be here, or in the error handler further up?
$scope.$emit('guacTunnelError', $scope.guac, status.code);
}; };
// Notify of disconnections (if not already notified of something else) // Fire events for tunnel state changes
$scope.tunnel.onstatechange = function onstatechange(state) { $scope.tunnel.onstatechange = function onstatechange(state) {
if (state === Guacamole.Tunnel.State.CLOSED) {
$scope.$emit('guacTunnelError', $scope.guac, "disconnected", state); switch (state) {
case Guacamole.Tunnel.State.CONNECTING:
$scope.$emit('guacTunnelStateChange', $scope.guac, "connecting");
break;
case Guacamole.Tunnel.State.OPEN:
$scope.$emit('guacTunnelStateChange', $scope.guac, "open");
break;
case Guacamole.Tunnel.State.CLOSED:
$scope.$emit('guacTunnelStateChange', $scope.guac, "closed");
break;
} }
}; };
// Connect // Connect