mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +00:00
GUACAMOLE-567: Add tunnel isConnected() function. Consider both OPEN and UNSTABLE status as connected.
This commit is contained in:
@@ -73,6 +73,17 @@ Guacamole.Tunnel = function() {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether this tunnel is currently connected.
|
||||||
|
*
|
||||||
|
* @returns {Boolean}
|
||||||
|
* true if this tunnel is currently connected, false otherwise.
|
||||||
|
*/
|
||||||
|
this.isConnected = function isConnected() {
|
||||||
|
return this.state === Guacamole.Tunnel.State.OPEN
|
||||||
|
|| this.state === Guacamole.Tunnel.State.UNSTABLE;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current state of this tunnel.
|
* The current state of this tunnel.
|
||||||
*
|
*
|
||||||
@@ -342,7 +353,7 @@ Guacamole.HTTPTunnel = function(tunnelURL, crossDomain, extraTunnelHeaders) {
|
|||||||
this.sendMessage = function() {
|
this.sendMessage = function() {
|
||||||
|
|
||||||
// Do not attempt to send messages if not connected
|
// Do not attempt to send messages if not connected
|
||||||
if (tunnel.state !== Guacamole.Tunnel.State.OPEN)
|
if (!tunnel.isConnected())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Do not attempt to send empty messages
|
// Do not attempt to send empty messages
|
||||||
@@ -384,7 +395,7 @@ Guacamole.HTTPTunnel = function(tunnelURL, crossDomain, extraTunnelHeaders) {
|
|||||||
function sendPendingMessages() {
|
function sendPendingMessages() {
|
||||||
|
|
||||||
// Do not attempt to send messages if not connected
|
// Do not attempt to send messages if not connected
|
||||||
if (tunnel.state !== Guacamole.Tunnel.State.OPEN)
|
if (!tunnel.isConnected())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (outputMessageBuffer.length > 0) {
|
if (outputMessageBuffer.length > 0) {
|
||||||
@@ -462,7 +473,7 @@ Guacamole.HTTPTunnel = function(tunnelURL, crossDomain, extraTunnelHeaders) {
|
|||||||
function parseResponse() {
|
function parseResponse() {
|
||||||
|
|
||||||
// Do not handle responses if not connected
|
// Do not handle responses if not connected
|
||||||
if (tunnel.state !== Guacamole.Tunnel.State.OPEN) {
|
if (!tunnel.isConnected()) {
|
||||||
|
|
||||||
// Clean up interval if polling
|
// Clean up interval if polling
|
||||||
if (interval !== null)
|
if (interval !== null)
|
||||||
@@ -835,7 +846,7 @@ Guacamole.WebSocketTunnel = function(tunnelURL) {
|
|||||||
this.sendMessage = function(elements) {
|
this.sendMessage = function(elements) {
|
||||||
|
|
||||||
// Do not attempt to send messages if not connected
|
// Do not attempt to send messages if not connected
|
||||||
if (tunnel.state !== Guacamole.Tunnel.State.OPEN)
|
if (!tunnel.isConnected())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Do not attempt to send empty messages
|
// Do not attempt to send empty messages
|
||||||
@@ -945,7 +956,7 @@ Guacamole.WebSocketTunnel = function(tunnelURL) {
|
|||||||
var opcode = elements.shift();
|
var opcode = elements.shift();
|
||||||
|
|
||||||
// Update state and UUID when first instruction received
|
// Update state and UUID when first instruction received
|
||||||
if (tunnel.state !== Guacamole.Tunnel.State.OPEN) {
|
if (tunnel.state === Guacamole.Tunnel.State.CONNECTING) {
|
||||||
|
|
||||||
// Associate tunnel UUID if received
|
// Associate tunnel UUID if received
|
||||||
if (opcode === Guacamole.Tunnel.INTERNAL_DATA_OPCODE)
|
if (opcode === Guacamole.Tunnel.INTERNAL_DATA_OPCODE)
|
||||||
|
Reference in New Issue
Block a user