mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUAC-549: Use new onerror/onack handlers. Translate Guacamole.Status codes to human-readable messages.
This commit is contained in:
@@ -61,7 +61,7 @@
|
||||
<script type="text/javascript" src="scripts/lib/filesaver/filesaver.js"></script>
|
||||
|
||||
<!-- guacamole-common-js -->
|
||||
<script type="text/javascript" src="guacamole-common-js/all.min.js"></script>
|
||||
<script type="text/javascript" src="guacamole-common-js/all.js"></script>
|
||||
|
||||
<!-- guacamole-default-webapp scripts -->
|
||||
<script type="text/javascript" src="scripts/session.js"></script>
|
||||
@@ -101,8 +101,6 @@
|
||||
// Tie UI to client
|
||||
GuacUI.Client.attach(guac);
|
||||
|
||||
try {
|
||||
|
||||
// Calculate optimal width/height for display
|
||||
var pixel_density = window.devicePixelRatio || 1;
|
||||
var optimal_dpi = pixel_density * 96;
|
||||
@@ -137,11 +135,12 @@
|
||||
connect_string += "&video=" + encodeURIComponent(mimetype);
|
||||
});
|
||||
|
||||
try {
|
||||
guac.connect(connect_string);
|
||||
|
||||
}
|
||||
catch (e) {
|
||||
GuacUI.Client.showError("Cannot Connect", e.message);
|
||||
catch (status) {
|
||||
var message = GuacUI.Client.errors[status.code] || GuacUI.Client.errors.DEFAULT;
|
||||
GuacUI.Client.showError("Cannot Connect", message);
|
||||
}
|
||||
|
||||
}, 0);
|
||||
|
@@ -63,6 +63,104 @@ GuacUI.Client = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Enumeration of all error messages for each applicable error code.
|
||||
*/
|
||||
"errors": {
|
||||
|
||||
0x0201: "The Guacamole server has rejected this connection attempt \
|
||||
because there are too many active connections. Please wait \
|
||||
a few minutes and try again.",
|
||||
|
||||
0x0202: "The remote desktop server encountered an error and has closed \
|
||||
the connection. Please try again or contact your system \
|
||||
administrator.",
|
||||
|
||||
0x0203: "The Guacamole server has closed the connection because the \
|
||||
remote desktop is taking too long to respond. Please try \
|
||||
again or contact your system administrator.",
|
||||
|
||||
0x0204: "The requested connection does not exist. Please check the \
|
||||
connection name and try again.",
|
||||
|
||||
0x0205: "This connection is currently in use, and concurrent access to \
|
||||
this connection is not allowed. Please try again later.",
|
||||
|
||||
0x0301: "You do not have permission to access this connection because \
|
||||
you are not logged in. Please log in and try again.",
|
||||
|
||||
0x0303: "You do not have permission to access this connection. If you \
|
||||
require access, please ask your system administrator to add \
|
||||
you the list of allowed users, or check your system settings.",
|
||||
|
||||
0x0308: "The Guacamole server has closed the connection because there \
|
||||
has been no response from your browser for long enough that \
|
||||
it appeared to be disconnected. This is commonly caused by \
|
||||
network problems, such as spotty wireless signal, or simply \
|
||||
very slow network speeds. Please check your network and try \
|
||||
again.",
|
||||
|
||||
0x031D: "The Guacamole server is denying access to this connection \
|
||||
because you have exhausted the limit for simultaneous \
|
||||
connection use by an individual user. Please close one or \
|
||||
more connections and try again.",
|
||||
|
||||
"DEFAULT": "An internal error has occurred within the Guacamole \
|
||||
server, and the connection has been terminated. If \
|
||||
the problem persists, please notify your system \
|
||||
administrator, or check your system logs."
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Enumeration of all error messages for each applicable error code. This
|
||||
* list is specific to file uploads.
|
||||
*/
|
||||
"upload_errors": {
|
||||
|
||||
0x0100: "File transfer is either not supported or not enabled. Please \
|
||||
contact your system administrator, or check your system logs.",
|
||||
|
||||
0x0201: "Too many files are currently being transferred. Please wait \
|
||||
for existing transfers to complete, and then try again.",
|
||||
|
||||
0x0202: "The remote desktop server encountered an error during \
|
||||
transfer. Please try again or contact your system \
|
||||
administrator.",
|
||||
|
||||
0x0203: "The file cannot be transferred because the remote desktop \
|
||||
server is taking too long to respond. Please try again or \
|
||||
or contact your system administrator.",
|
||||
|
||||
0x0204: "The destination for the file transfer does not exist. Please \
|
||||
check that the destionation exists and try again.",
|
||||
|
||||
0x0205: "The destination for the file transfer is currently locked. \
|
||||
Please wait for any in-progress tasks to complete and try \
|
||||
again.",
|
||||
|
||||
0x0301: "You do not have permission to upload this file because you \
|
||||
are not logged in. Please log in and try again.",
|
||||
|
||||
0x0303: "You do not have permission to upload this file. If you \
|
||||
require access, please check your system settings, or \
|
||||
check with your system administrator.",
|
||||
|
||||
0x0308: "The file transfer has stalled. This is commonly caused by \
|
||||
network problems, such as spotty wireless signal, or \
|
||||
simply very slow network speeds. Please check your \
|
||||
network and try again.",
|
||||
|
||||
0x031D: "Too many files are currently being transferred. Please wait \
|
||||
for existing transfers to complete, and then try again.",
|
||||
|
||||
"DEFAULT": "An internal error has occurred within the Guacamole \
|
||||
server, and the connection has been terminated. If \
|
||||
the problem persists, please notify your system \
|
||||
administrator, or check your system logs.",
|
||||
|
||||
},
|
||||
|
||||
/* Constants */
|
||||
|
||||
"LONG_PRESS_DETECT_TIMEOUT" : 800, /* milliseconds */
|
||||
@@ -780,13 +878,14 @@ GuacUI.Client.attach = function(guac) {
|
||||
* receives an error.
|
||||
*/
|
||||
|
||||
guac.onerror = function(error) {
|
||||
guac.onerror = function(status) {
|
||||
|
||||
// Disconnect, if connected
|
||||
guac.disconnect();
|
||||
|
||||
// Display error message
|
||||
GuacUI.Client.showError("Connection Error", error);
|
||||
var message = GuacUI.Client.errors[status.code] || GuacUI.Client.errors.DEFAULT;
|
||||
GuacUI.Client.showError("Connection Error", message);
|
||||
|
||||
};
|
||||
|
||||
@@ -1157,12 +1256,14 @@ GuacUI.Client.attach = function(guac) {
|
||||
|
||||
// Invalidate stream on all errors
|
||||
// Continue upload when acknowledged
|
||||
stream.onack = function(text, code) {
|
||||
stream.onack = function(status) {
|
||||
|
||||
// Handle codes
|
||||
if (code >= 0x0100) {
|
||||
// Handle errors
|
||||
if (status.isError()) {
|
||||
valid = false;
|
||||
upload.showError(text);
|
||||
var message = GuacUI.Client.upload_errors[status.code]
|
||||
|| GuacUI.Client.upload_errors.DEFAULT;
|
||||
upload.showError(message);
|
||||
}
|
||||
|
||||
// Abort upload if stream is invalid
|
||||
|
Reference in New Issue
Block a user