You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by vn...@apache.org on 2017/11/08 18:51:39 UTC

[1/3] incubator-guacamole-client git commit: GUACAMOLE-431: Move setState to base Tunnel class

Repository: incubator-guacamole-client
Updated Branches:
  refs/heads/master 0611fe8ff -> 5a6c47a9b


GUACAMOLE-431: Move setState to base Tunnel class

Move `setState()` to Tunnel class to avoid repetition.


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

Branch: refs/heads/master
Commit: d778ad7035a39710a6316905cd430203daad100a
Parents: 0611fe8
Author: Or Cohen <or...@strigo.io>
Authored: Tue Nov 7 11:17:42 2017 +0200
Committer: Or Cohen <or...@strigo.io>
Committed: Tue Nov 7 12:41:40 2017 +0200

----------------------------------------------------------------------
 .../src/main/webapp/modules/Tunnel.js           | 64 +++++++++-----------
 1 file changed, 28 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/d778ad70/guacamole-common-js/src/main/webapp/modules/Tunnel.js
----------------------------------------------------------------------
diff --git a/guacamole-common-js/src/main/webapp/modules/Tunnel.js b/guacamole-common-js/src/main/webapp/modules/Tunnel.js
index 508aa4c..3fa6ef7 100644
--- a/guacamole-common-js/src/main/webapp/modules/Tunnel.js
+++ b/guacamole-common-js/src/main/webapp/modules/Tunnel.js
@@ -55,6 +55,25 @@ Guacamole.Tunnel = function() {
     this.sendMessage = function(elements) {};
 
     /**
+     * Changes the stored numeric state of this tunnel, firing the onstatechange
+     * event if the new state is different and a handler has been defined.
+     *
+     * @private
+     * @param {Number} state
+     *     The new state of this tunnel.
+     */
+    this.setState = function(state) {
+
+        // Notify only if state changes
+        if (state !== this.state) {
+            this.state = state;
+            if (this.onstatechange)
+                this.onstatechange(state);
+        }
+
+    };
+
+    /**
      * The current state of this tunnel.
      * 
      * @type {Number}
@@ -239,14 +258,11 @@ Guacamole.HTTPTunnel = function(tunnelURL, crossDomain) {
 
         }
 
-        // Mark as closed
-        tunnel.state = Guacamole.Tunnel.State.CLOSED;
-
         // Reset output message buffer
         sendingMessages = false;
 
-        if (tunnel.onstatechange)
-            tunnel.onstatechange(tunnel.state);
+        // Mark as closed
+        tunnel.setState(Guacamole.Tunnel.State.CLOSED);
 
     }
 
@@ -566,9 +582,8 @@ Guacamole.HTTPTunnel = function(tunnelURL, crossDomain) {
             // Get UUID from response
             tunnel.uuid = connect_xmlhttprequest.responseText;
 
-            tunnel.state = Guacamole.Tunnel.State.OPEN;
-            if (tunnel.onstatechange)
-                tunnel.onstatechange(tunnel.state);
+            // Mark as open
+            tunnel.setState(Guacamole.Tunnel.State.OPEN);
 
             // Start reading data
             handleResponse(makeRequest());
@@ -698,9 +713,7 @@ Guacamole.WebSocketTunnel = function(tunnelURL) {
             tunnel.onerror(status);
 
         // Mark as closed
-        tunnel.state = Guacamole.Tunnel.State.CLOSED;
-        if (tunnel.onstatechange)
-            tunnel.onstatechange(tunnel.state);
+        tunnel.setState(Guacamole.Tunnel.State.CLOSED);
 
         socket.close();
 
@@ -814,9 +827,7 @@ Guacamole.WebSocketTunnel = function(tunnelURL) {
                             tunnel.uuid = elements[0];
 
                         // Tunnel is now open and UUID is available
-                        tunnel.state = Guacamole.Tunnel.State.OPEN;
-                        if (tunnel.onstatechange)
-                            tunnel.onstatechange(tunnel.state);
+                        tunnel.setState(Guacamole.Tunnel.State.OPEN);
 
                     }
 
@@ -1060,25 +1071,6 @@ Guacamole.StaticHTTPTunnel = function StaticHTTPTunnel(url, crossDomain) {
     var xhr = null;
 
     /**
-     * Changes the stored numeric state of this tunnel, firing the onstatechange
-     * event if the new state is different and a handler has been defined.
-     *
-     * @private
-     * @param {Number} state
-     *     The new state of this tunnel.
-     */
-    var setState = function setState(state) {
-
-        // Notify only if state changes
-        if (state !== tunnel.state) {
-            tunnel.state = state;
-            if (tunnel.onstatechange)
-                tunnel.onstatechange(state);
-        }
-
-    };
-
-    /**
      * Returns the Guacamole protocol status code which most closely
      * represents the given HTTP status code.
      *
@@ -1133,7 +1125,7 @@ Guacamole.StaticHTTPTunnel = function StaticHTTPTunnel(url, crossDomain) {
         tunnel.disconnect();
 
         // Connection is now starting
-        setState(Guacamole.Tunnel.State.CONNECTING);
+        tunnel.setState(Guacamole.Tunnel.State.CONNECTING);
 
         // Start a new connection
         xhr = new XMLHttpRequest();
@@ -1160,7 +1152,7 @@ Guacamole.StaticHTTPTunnel = function StaticHTTPTunnel(url, crossDomain) {
             if (xhr.readyState === 3 || xhr.readyState === 4) {
 
                 // Connection is open
-                setState(Guacamole.Tunnel.State.OPEN);
+                tunnel.setState(Guacamole.Tunnel.State.OPEN);
 
                 var buffer = xhr.responseText;
                 var length = buffer.length;
@@ -1200,7 +1192,7 @@ Guacamole.StaticHTTPTunnel = function StaticHTTPTunnel(url, crossDomain) {
         }
 
         // Connection is now closed
-        setState(Guacamole.Tunnel.State.CLOSED);
+        tunnel.setState(Guacamole.Tunnel.State.CLOSED);
 
     };
 


[2/3] incubator-guacamole-client git commit: GUACAMOLE-431: Fix tunnel stuck in CLOSED state

Posted by vn...@apache.org.
GUACAMOLE-431: Fix tunnel stuck in CLOSED state

When the tunnel is closed and another `connect()` call is made, it stops
notifying about state changes (`onstatechanges`) if the connection continues
to fail.

This patch sets the state to `CONNECTING` when calling `connect()`.


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

Branch: refs/heads/master
Commit: 63f603ec9dfe91e33f4de83f27b6a81e1992c13a
Parents: d778ad7
Author: Or Cohen <or...@strigo.io>
Authored: Tue Nov 7 11:47:57 2017 +0200
Committer: Or Cohen <or...@strigo.io>
Committed: Tue Nov 7 12:41:51 2017 +0200

----------------------------------------------------------------------
 guacamole-common-js/src/main/webapp/modules/Tunnel.js | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/63f603ec/guacamole-common-js/src/main/webapp/modules/Tunnel.js
----------------------------------------------------------------------
diff --git a/guacamole-common-js/src/main/webapp/modules/Tunnel.js b/guacamole-common-js/src/main/webapp/modules/Tunnel.js
index 3fa6ef7..2b1826d 100644
--- a/guacamole-common-js/src/main/webapp/modules/Tunnel.js
+++ b/guacamole-common-js/src/main/webapp/modules/Tunnel.js
@@ -564,6 +564,9 @@ Guacamole.HTTPTunnel = function(tunnelURL, crossDomain) {
         // Start waiting for connect
         reset_timeout();
 
+        // Mark the tunnel as connecting
+        tunnel.setState(Guacamole.Tunnel.State.CONNECTING);
+
         // Start tunnel and connect
         var connect_xmlhttprequest = new XMLHttpRequest();
         connect_xmlhttprequest.onreadystatechange = function() {
@@ -760,6 +763,9 @@ Guacamole.WebSocketTunnel = function(tunnelURL) {
 
         reset_timeout();
 
+        // Mark the tunnel as connecting
+        tunnel.setState(Guacamole.Tunnel.State.CONNECTING);
+
         // Connect socket
         socket = new WebSocket(tunnelURL + "?" + data, "guacamole");
 


[3/3] incubator-guacamole-client git commit: GUACAMOLE-431: Merge Fix tunnel handling of CLOSED state.

Posted by vn...@apache.org.
GUACAMOLE-431: Merge Fix tunnel handling of CLOSED state.


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

Branch: refs/heads/master
Commit: 5a6c47a9b2693b08564299e7751e964c8d5010ef
Parents: 0611fe8 63f603e
Author: Nick Couchman <vn...@apache.org>
Authored: Wed Nov 8 13:50:51 2017 -0500
Committer: Nick Couchman <vn...@apache.org>
Committed: Wed Nov 8 13:50:51 2017 -0500

----------------------------------------------------------------------
 .../src/main/webapp/modules/Tunnel.js           | 70 ++++++++++----------
 1 file changed, 34 insertions(+), 36 deletions(-)
----------------------------------------------------------------------