More JSDoc and cleanup.
[guacamole-common-js.git] / src / main / resources / tunnel.js
index e092088..d287589 100644 (file)
 // Guacamole namespace
 var Guacamole = Guacamole || {};
 
+/**
+ * Core object providing abstract communication for Guacamole. This object
+ * is a null implementation whose functions do nothing. Guacamole applications
+ * should use {@link Guacamole.HTTPTunnel} instead, or implement their own tunnel based
+ * on this one.
+ * 
+ * @constructor
+ * @see Guacamole.HTTPTunnel
+ */
+Guacamole.Tunnel = function() {
+    
+    this.connect = function(data) {};
+    
+    this.disconnect = function() {};
+    
+    this.sendMessage = function(message) {};
+    
+    this.onerror = null;
+    this.oninstruction = null;
+
+};
+
+/**
+ * Guacamole Tunnel implemented over HTTP via XMLHttpRequest.
+ * 
+ * @constructor
+ * @augments Guacamole.Tunnel
+ * @param {String} tunnelURL The URL of the HTTP tunneling service.
+ */
 Guacamole.HTTPTunnel = function(tunnelURL) {
 
     var tunnel = this;
@@ -44,10 +73,6 @@ Guacamole.HTTPTunnel = function(tunnelURL) {
     var sendingMessages = 0;
     var outputMessageBuffer = "";
 
-    // Handlers
-    tunnel.onerror = null;
-    tunnel.oninstruction = null;
-
     function sendMessage(message) {
 
         // Do not attempt to send messages if not connected
@@ -267,4 +292,6 @@ Guacamole.HTTPTunnel = function(tunnelURL) {
     tunnel.disconnect = disconnect;
     tunnel.sendMessage = sendMessage;
 
-}
+};
+
+Guacamole.HTTPTunnel.prototype = new Guacamole.Tunnel();