GUACAMOLE-567: Move client instability state to own flag. Actual current 
connection state is lost otherwise.


Project: http://git-wip-us.apache.org/repos/asf/guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-client/commit/fe07cf9b
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-client/tree/fe07cf9b
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-client/diff/fe07cf9b

Branch: refs/heads/master
Commit: fe07cf9b703e2aa9a83ed5ce57e51fe6cb33105d
Parents: 402ddb5
Author: Michael Jumper <mjum...@apache.org>
Authored: Sat Sep 1 19:19:08 2018 -0700
Committer: Michael Jumper <mjum...@apache.org>
Committed: Fri Sep 7 12:20:28 2018 -0700

----------------------------------------------------------------------
 .../app/client/controllers/clientController.js  |  2 +-
 .../webapp/app/client/types/ManagedClient.js    |  8 ++--
 .../app/client/types/ManagedClientState.js      | 40 +++++++++++++++-----
 3 files changed, 34 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/fe07cf9b/guacamole/src/main/webapp/app/client/controllers/clientController.js
----------------------------------------------------------------------
diff --git 
a/guacamole/src/main/webapp/app/client/controllers/clientController.js 
b/guacamole/src/main/webapp/app/client/controllers/clientController.js
index ffbe3c5..41c6ba6 100644
--- a/guacamole/src/main/webapp/app/client/controllers/clientController.js
+++ b/guacamole/src/main/webapp/app/client/controllers/clientController.js
@@ -635,7 +635,7 @@ angular.module('client').controller('clientController', 
['$scope', '$routeParams
      *     otherwise.
      */
     $scope.isConnectionUnstable = function isConnectionUnstable() {
-        return $scope.client && $scope.client.clientState.connectionState === 
ManagedClientState.ConnectionState.UNSTABLE;
+        return $scope.client && $scope.client.clientState.tunnelUnstable;
     };
 
     // Show status dialog when connection status changes

http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/fe07cf9b/guacamole/src/main/webapp/app/client/types/ManagedClient.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/client/types/ManagedClient.js 
b/guacamole/src/main/webapp/app/client/types/ManagedClient.js
index 09c96a9..a9bc3be 100644
--- a/guacamole/src/main/webapp/app/client/types/ManagedClient.js
+++ b/guacamole/src/main/webapp/app/client/types/ManagedClient.js
@@ -346,16 +346,14 @@ angular.module('client').factory('ManagedClient', 
['$rootScope', '$injector',
                             ManagedClientState.ConnectionState.CONNECTING);
                         break;
 
-                    // Connection is established
+                    // Connection is established / no longer unstable
                     case Guacamole.Tunnel.State.OPEN:
-                        
ManagedClientState.setConnectionState(managedClient.clientState,
-                            ManagedClientState.ConnectionState.CONNECTED);
+                        
ManagedClientState.setTunnelUnstable(managedClient.clientState, false);
                         break;
 
                     // Connection is established but misbehaving
                     case Guacamole.Tunnel.State.UNSTABLE:
-                        
ManagedClientState.setConnectionState(managedClient.clientState,
-                            ManagedClientState.ConnectionState.UNSTABLE);
+                        
ManagedClientState.setTunnelUnstable(managedClient.clientState, true);
                         break;
 
                     // Connection has closed

http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/fe07cf9b/guacamole/src/main/webapp/app/client/types/ManagedClientState.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/client/types/ManagedClientState.js 
b/guacamole/src/main/webapp/app/client/types/ManagedClientState.js
index 1a26b0d..10f71b4 100644
--- a/guacamole/src/main/webapp/app/client/types/ManagedClientState.js
+++ b/guacamole/src/main/webapp/app/client/types/ManagedClientState.js
@@ -46,6 +46,16 @@ angular.module('client').factory('ManagedClientState', 
[function defineManagedCl
         this.connectionState = template.connectionState || 
ManagedClientState.ConnectionState.IDLE;
 
         /**
+         * Whether the network connection used by the tunnel seems unstable. If
+         * the network connection is unstable, the remote desktop connection
+         * may perform poorly or disconnect.
+         *
+         * @type Boolean
+         * @default false
+         */
+        this.tunnelUnstable = template.tunnelUnstable || false;
+
+        /**
          * The status code of the current error condition, if connectionState
          * is CLIENT_ERROR or TUNNEL_ERROR. For all other connectionState
          * values, this will be @link{Guacamole.Status.Code.SUCCESS}.
@@ -94,15 +104,6 @@ angular.module('client').factory('ManagedClientState', 
[function defineManagedCl
         CONNECTED : "CONNECTED",
 
         /**
-         * The Guacamole connection has been successfully established, but the
-         * network connection seems unstable. The connection may perform poorly
-         * or disconnect.
-         * 
-         * @type String
-         */
-        UNSTABLE : "UNSTABLE",
-
-        /**
          * The Guacamole connection has terminated successfully. No errors are
          * indicated.
          * 
@@ -130,7 +131,9 @@ angular.module('client').factory('ManagedClientState', 
[function defineManagedCl
 
     /**
      * Sets the current client state and, if given, the associated status code.
-     * If an error is already represented, this function has no effect.
+     * If an error is already represented, this function has no effect. If the
+     * client state was previously marked as unstable, that flag is implicitly
+     * cleared.
      *
      * @param {ManagedClientState} clientState
      *     The ManagedClientState to update.
@@ -153,6 +156,7 @@ angular.module('client').factory('ManagedClientState', 
[function defineManagedCl
 
         // Update connection state
         clientState.connectionState = connectionState;
+        clientState.tunnelUnstable = false;
 
         // Set status code, if given
         if (statusCode)
@@ -160,6 +164,22 @@ angular.module('client').factory('ManagedClientState', 
[function defineManagedCl
 
     };
 
+    /**
+     * Updates the given client state, setting whether the underlying tunnel
+     * is currently unstable. An unstable tunnel is not necessarily
+     * disconnected, but appears to be misbehaving and may be disconnected.
+     *
+     * @param {ManagedClientState} clientState
+     *     The ManagedClientState to update.
+     *
+     * @param {Boolean} unstable
+     *     Whether the underlying tunnel of the connection currently appears
+     *     unstable.
+     */
+    ManagedClientState.setTunnelUnstable = function 
setTunnelUnstable(clientState, unstable) {
+        clientState.tunnelUnstable = unstable;
+    };
+
     return ManagedClientState;
 
 }]);
\ No newline at end of file

Reply via email to