mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUACAMOLE-221: Define event for client-side receipt of a tunnel UUID.
This commit is contained in:
@@ -73,6 +73,20 @@ Guacamole.Tunnel = function() {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes the stored UUID that uniquely identifies this tunnel, firing the
|
||||||
|
* onuuid event if a handler has been defined.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {String} uuid
|
||||||
|
* The new state of this tunnel.
|
||||||
|
*/
|
||||||
|
this.setUUID = function setUUID(uuid) {
|
||||||
|
this.uuid = uuid;
|
||||||
|
if (this.onuuid)
|
||||||
|
this.onuuid(uuid);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether this tunnel is currently connected.
|
* Returns whether this tunnel is currently connected.
|
||||||
*
|
*
|
||||||
@@ -119,6 +133,15 @@ Guacamole.Tunnel = function() {
|
|||||||
*/
|
*/
|
||||||
this.uuid = null;
|
this.uuid = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fired when the UUID that uniquely identifies this tunnel is known.
|
||||||
|
*
|
||||||
|
* @event
|
||||||
|
* @param {String}
|
||||||
|
* The UUID uniquely identifying this tunnel.
|
||||||
|
*/
|
||||||
|
this.onuuid = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fired whenever an error is encountered by the tunnel.
|
* Fired whenever an error is encountered by the tunnel.
|
||||||
*
|
*
|
||||||
@@ -706,7 +729,7 @@ Guacamole.HTTPTunnel = function(tunnelURL, crossDomain, extraTunnelHeaders) {
|
|||||||
reset_timeout();
|
reset_timeout();
|
||||||
|
|
||||||
// Get UUID from response
|
// Get UUID from response
|
||||||
tunnel.uuid = connect_xmlhttprequest.responseText;
|
tunnel.setUUID(connect_xmlhttprequest.responseText);
|
||||||
|
|
||||||
// Mark as open
|
// Mark as open
|
||||||
tunnel.setState(Guacamole.Tunnel.State.OPEN);
|
tunnel.setState(Guacamole.Tunnel.State.OPEN);
|
||||||
@@ -1019,7 +1042,7 @@ Guacamole.WebSocketTunnel = function(tunnelURL) {
|
|||||||
|
|
||||||
// Associate tunnel UUID if received
|
// Associate tunnel UUID if received
|
||||||
if (opcode === Guacamole.Tunnel.INTERNAL_DATA_OPCODE)
|
if (opcode === Guacamole.Tunnel.INTERNAL_DATA_OPCODE)
|
||||||
tunnel.uuid = elements[0];
|
tunnel.setUUID(elements[0]);
|
||||||
|
|
||||||
// Tunnel is now open and UUID is available
|
// Tunnel is now open and UUID is available
|
||||||
tunnel.setState(Guacamole.Tunnel.State.OPEN);
|
tunnel.setState(Guacamole.Tunnel.State.OPEN);
|
||||||
@@ -1155,11 +1178,18 @@ Guacamole.ChainedTunnel = function(tunnelChain) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
function commit_tunnel() {
|
function commit_tunnel() {
|
||||||
|
|
||||||
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;
|
||||||
chained_tunnel.uuid = tunnel.uuid;
|
tunnel.onuuid = chained_tunnel.onuuid;
|
||||||
|
|
||||||
|
// Assign UUID if already known
|
||||||
|
if (tunnel.uuid)
|
||||||
|
chained_tunnel.setUUID(tunnel.uuid);
|
||||||
|
|
||||||
committedTunnel = tunnel;
|
committedTunnel = tunnel;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wrap own onstatechange within current tunnel
|
// Wrap own onstatechange within current tunnel
|
||||||
|
Reference in New Issue
Block a user