From 0b70e587ec4047e09082b52f1f9f4fee39a3b966 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 9 Mar 2012 12:27:16 -0800 Subject: [PATCH] Implemented WebSocketTunnel. --- src/main/resources/tunnel.js | 86 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 74 insertions(+), 12 deletions(-) diff --git a/src/main/resources/tunnel.js b/src/main/resources/tunnel.js index 99a87d3..50d5969 100644 --- a/src/main/resources/tunnel.js +++ b/src/main/resources/tunnel.js @@ -503,12 +503,38 @@ Guacamole.WebSocketTunnel = function(tunnelURL) { } - this.sendMessage = function(message) { + this.sendMessage = function(elements) { // Do not attempt to send messages if not connected if (currentState != STATE_CONNECTED) return; + // Do not attempt to send empty messages + if (arguments.length == 0) + return; + + /** + * Converts the given value to a length/string pair for use as an + * element in a Guacamole instruction. + * + * @param value The value to convert. + * @return {String} The converted value. + */ + 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