Test for WebSocket, default to HTTP.
[guacamole.git] / src / main / webapp / client.xhtml
index fb8c20c..ba9a5a4 100644 (file)
             window.onload = function() {
                 window.setTimeout(function() {
 
+                    var tunnel;
+
+                    // If WebSocket available, try to use it.
+                    if (window.WebSocket)
+                        tunnel = new Guacamole.WebSocketTunnel("websocket-tunnel")
+
+                    // If no WebSocket, then use HTTP.
+                    else
+                        tunnel = new Guacamole.HTTPTunnel("tunnel")
+
                     // Instantiate client
-                    var guac = new Guacamole.Client(
-                        new Guacamole.HTTPTunnel("tunnel")
-                    );
+                    var guac = new Guacamole.Client(tunnel);
 
                     // Add client to UI
                     guac.getDisplay().className = "software-cursor";