Merge pull request #210 from glyptodon/chained-tunnel-reconnect

GUAC-1084: Support re-use of a single ChainedTunnel instance
This commit is contained in:
James Muehlner
2015-07-07 21:27:26 -07:00

View File

@@ -842,6 +842,15 @@ Guacamole.ChainedTunnel = function(tunnel_chain) {
*/ */
var tunnels = []; var tunnels = [];
/**
* The tunnel committed via commit_tunnel(), if any, or null if no tunnel
* has yet been committed.
*
* @private
* @type Guacamole.Tunnel
*/
var committedTunnel = null;
// Load all tunnels into array // Load all tunnels into array
for (var i=0; i<arguments.length; i++) for (var i=0; i<arguments.length; i++)
tunnels.push(arguments[i]); tunnels.push(arguments[i]);
@@ -893,6 +902,7 @@ Guacamole.ChainedTunnel = function(tunnel_chain) {
tunnel.onstatechange = chained_tunnel.onstatechange; tunnel.onstatechange = chained_tunnel.onstatechange;
tunnel.oninstruction = chained_tunnel.oninstruction; tunnel.oninstruction = chained_tunnel.oninstruction;
tunnel.onerror = chained_tunnel.onerror; tunnel.onerror = chained_tunnel.onerror;
committedTunnel = tunnel;
} }
// Wrap own onstatechange within current tunnel // Wrap own onstatechange within current tunnel
@@ -948,8 +958,8 @@ Guacamole.ChainedTunnel = function(tunnel_chain) {
// Remember connect data // Remember connect data
connect_data = data; connect_data = data;
// Get first tunnel // Get committed tunnel if exists or the first tunnel on the list
var next_tunnel = tunnels.shift(); var next_tunnel = committedTunnel ? committedTunnel : tunnels.shift();
// Attach first tunnel // Attach first tunnel
if (next_tunnel) if (next_tunnel)