mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +00:00
GUAC-549: Throw status instead of error for connect() in tunnel and client. Pass status instead of message/code parameters for onerror event handlers.
This commit is contained in:
@@ -142,9 +142,9 @@ Guacamole.Client = function(tunnel) {
|
||||
// Array of allocated output streams by index
|
||||
var output_streams = [];
|
||||
|
||||
tunnel.onerror = function(message) {
|
||||
tunnel.onerror = function(status) {
|
||||
if (guac_client.onerror)
|
||||
guac_client.onerror(message);
|
||||
guac_client.onerror(status);
|
||||
};
|
||||
|
||||
function setState(state) {
|
||||
@@ -394,8 +394,8 @@ Guacamole.Client = function(tunnel) {
|
||||
* is being closed.
|
||||
*
|
||||
* @event
|
||||
* @param {String} reason A human-readable reason describing the error.
|
||||
* @param {Number} code The error code associated with the error.
|
||||
* @param {Guacamole.Status} status A status object which describes the
|
||||
* error.
|
||||
*/
|
||||
this.onerror = null;
|
||||
|
||||
@@ -800,7 +800,7 @@ Guacamole.Client = function(tunnel) {
|
||||
|
||||
// Call handler if defined
|
||||
if (guac_client.onerror)
|
||||
guac_client.onerror(reason, code);
|
||||
guac_client.onerror(new Guacamole.Status(code, reason));
|
||||
|
||||
guac_client.disconnect();
|
||||
|
||||
@@ -1259,6 +1259,7 @@ Guacamole.Client = function(tunnel) {
|
||||
*
|
||||
* @param data Arbitrary connection data to be sent to the underlying
|
||||
* tunnel during the connection process.
|
||||
* @throws {Guacamole.Status} If an error occurs during connection.
|
||||
*/
|
||||
this.connect = function(data) {
|
||||
|
||||
@@ -1267,9 +1268,9 @@ Guacamole.Client = function(tunnel) {
|
||||
try {
|
||||
tunnel.connect(data);
|
||||
}
|
||||
catch (e) {
|
||||
catch (status) {
|
||||
setState(STATE_IDLE);
|
||||
throw e;
|
||||
throw status;
|
||||
}
|
||||
|
||||
// Ping every 5 seconds (ensure connection alive)
|
||||
|
Reference in New Issue
Block a user