mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +00:00
Partial implementation of new format instructions in output.
This commit is contained in:
@@ -102,7 +102,7 @@ Guacamole.Client = function(display, tunnel) {
|
||||
if (!isConnected())
|
||||
return;
|
||||
|
||||
tunnel.sendMessage("key:" + keysym + "," + pressed + ";");
|
||||
tunnel.sendMessage("key", keysym, pressed);
|
||||
};
|
||||
|
||||
guac_client.sendMouseState = function(mouseState) {
|
||||
@@ -128,7 +128,7 @@ Guacamole.Client = function(display, tunnel) {
|
||||
if (mouseState.down) buttonMask |= 16;
|
||||
|
||||
// Send message
|
||||
tunnel.sendMessage("mouse:" + mouseState.x + "," + mouseState.y + "," + buttonMask + ";");
|
||||
tunnel.sendMessage("mouse", mouseState.x, mouseState.y, buttonMask);
|
||||
};
|
||||
|
||||
guac_client.setClipboard = function(data) {
|
||||
@@ -137,7 +137,7 @@ Guacamole.Client = function(display, tunnel) {
|
||||
if (!isConnected())
|
||||
return;
|
||||
|
||||
tunnel.sendMessage("clipboard:" + escapeGuacamoleString(data) + ";");
|
||||
tunnel.sendMessage("clipboard", data);
|
||||
};
|
||||
|
||||
// Handlers
|
||||
@@ -384,7 +384,7 @@ Guacamole.Client = function(display, tunnel) {
|
||||
|
||||
// Send sync response when layers are finished
|
||||
if (layersToSync == 0)
|
||||
tunnel.sendMessage("sync:" + timestamp + ";");
|
||||
tunnel.sendMessage("sync", timestamp);
|
||||
|
||||
}
|
||||
|
||||
@@ -402,7 +402,7 @@ Guacamole.Client = function(display, tunnel) {
|
||||
// If all layers are ready, then we didn't install any hooks.
|
||||
// Send sync message now,
|
||||
if (layersToSync == 0)
|
||||
tunnel.sendMessage("sync:" + timestamp + ";");
|
||||
tunnel.sendMessage("sync", timestamp);
|
||||
|
||||
}
|
||||
|
||||
@@ -425,35 +425,13 @@ Guacamole.Client = function(display, tunnel) {
|
||||
&& currentState != STATE_DISCONNECTING) {
|
||||
|
||||
setState(STATE_DISCONNECTING);
|
||||
tunnel.sendMessage("disconnect;");
|
||||
tunnel.sendMessage("disconnect");
|
||||
tunnel.disconnect();
|
||||
setState(STATE_DISCONNECTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function escapeGuacamoleString(str) {
|
||||
|
||||
var escapedString = "";
|
||||
|
||||
for (var i=0; i<str.length; i++) {
|
||||
|
||||
var c = str.charAt(i);
|
||||
if (c == ",")
|
||||
escapedString += "\\c";
|
||||
else if (c == ";")
|
||||
escapedString += "\\s";
|
||||
else if (c == "\\")
|
||||
escapedString += "\\\\";
|
||||
else
|
||||
escapedString += c;
|
||||
|
||||
}
|
||||
|
||||
return escapedString;
|
||||
|
||||
}
|
||||
|
||||
guac_client.disconnect = disconnect;
|
||||
guac_client.connect = function(data) {
|
||||
|
||||
|
@@ -48,10 +48,10 @@ Guacamole.Tunnel = function() {
|
||||
* Send the given message through the tunnel to the service on the other
|
||||
* side. All messages are guaranteed to be received in the order sent.
|
||||
*
|
||||
* @param {String} message The message to send to the service on the other
|
||||
* side of the tunnel.
|
||||
* @param {...} elements The elements of the message to send to the
|
||||
* service on the other side of the tunnel.
|
||||
*/
|
||||
this.sendMessage = function(message) {};
|
||||
this.sendMessage = function(elements) {};
|
||||
|
||||
/**
|
||||
* Fired whenever an error is encountered by the tunnel.
|
||||
@@ -109,13 +109,32 @@ Guacamole.HTTPTunnel = function(tunnelURL) {
|
||||
var sendingMessages = false;
|
||||
var outputMessageBuffer = "";
|
||||
|
||||
this.sendMessage = function(message) {
|
||||
this.sendMessage = function() {
|
||||
|
||||
// Do not attempt to send messages if not connected
|
||||
if (currentState != STATE_CONNECTED)
|
||||
return;
|
||||
|
||||
// Add event to queue, restart send loop if finished.
|
||||
// Do not attempt to send empty messages
|
||||
if (arguments.length == 0)
|
||||
return;
|
||||
|
||||
function getElement(value) {
|
||||
var string = new String(value);
|
||||
return string.length + "." + string;
|
||||
}
|
||||
|
||||
// Initialized message with first element
|
||||
var message = getElement(arguments[0]);
|
||||
|
||||
// Append remaining elements
|
||||
for (var i=1; i<arguments.length; i++)
|
||||
message += "," + getElement(arguments[i]);
|
||||
|
||||
// Final terminator
|
||||
message += ";";
|
||||
|
||||
// Add message to buffer, restart send loop if finished.
|
||||
outputMessageBuffer += message;
|
||||
if (!sendingMessages)
|
||||
sendPendingMessages();
|
||||
|
Reference in New Issue
Block a user