mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 05:31:22 +00:00
Error handling, added data submission for connect.
This commit is contained in:
@@ -429,12 +429,19 @@ function GuacamoleClient(display, tunnel) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.disconnect = disconnect;
|
this.disconnect = disconnect;
|
||||||
this.connect = function() {
|
this.connect = function(data) {
|
||||||
|
|
||||||
setState(STATE_CONNECTING);
|
setState(STATE_CONNECTING);
|
||||||
tunnel.connect();
|
|
||||||
setState(STATE_WAITING);
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
tunnel.connect(data);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
setState(STATE_IDLE);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
setState(STATE_WAITING);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.escapeGuacamoleString = escapeGuacamoleString;
|
this.escapeGuacamoleString = escapeGuacamoleString;
|
||||||
|
@@ -213,13 +213,24 @@ function GuacamoleHTTPTunnel(tunnelURL) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function connect() {
|
function connect(data) {
|
||||||
|
|
||||||
// Start tunnel and connect synchronously
|
// Start tunnel and connect synchronously
|
||||||
var connect_xmlhttprequest = new XMLHttpRequest();
|
var connect_xmlhttprequest = new XMLHttpRequest();
|
||||||
connect_xmlhttprequest.open("POST", TUNNEL_CONNECT, false);
|
connect_xmlhttprequest.open("POST", TUNNEL_CONNECT, false);
|
||||||
connect_xmlhttprequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
connect_xmlhttprequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||||||
connect_xmlhttprequest.send(null);
|
connect_xmlhttprequest.send(data);
|
||||||
|
|
||||||
|
// If failure, throw error
|
||||||
|
if (connect_xmlhttprequest.status != 200) {
|
||||||
|
|
||||||
|
var message = connect_xmlhttprequest.getResponseHeader("X-Guacamole-Error-Message");
|
||||||
|
if (!message)
|
||||||
|
message = "Internal error";
|
||||||
|
|
||||||
|
throw new Error(message);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Get UUID from response
|
// Get UUID from response
|
||||||
tunnel_uuid = connect_xmlhttprequest.responseText;
|
tunnel_uuid = connect_xmlhttprequest.responseText;
|
||||||
|
Reference in New Issue
Block a user