瀏覽代碼

Timeout connection.

Joel Martin 15 年之前
父節點
當前提交
2a4e7d8a93
共有 1 個文件被更改,包括 8 次插入0 次删除
  1. 8 0
      include/vnc.js

+ 8 - 0
include/vnc.js

@@ -64,6 +64,7 @@ true_color     : false,
 
 
 b64encode      : true,  // false means UTF-8 on the wire
 b64encode      : true,  // false means UTF-8 on the wire
 //b64encode      : false,  // false means UTF-8 on the wire
 //b64encode      : false,  // false means UTF-8 on the wire
+connectTimeout : 1000,  // time to wait for connection
 
 
 
 
 // In preference order
 // In preference order
@@ -1476,6 +1477,13 @@ init_ws: function () {
         console.error("<< WebSocket.onerror");
         console.error("<< WebSocket.onerror");
     };
     };
 
 
+    setTimeout(function () {
+            if (RFB.ws.readyState === WebSocket.CONNECTING) {
+                RFB.updateState('failed', "Connect timeout");
+                RFB.ws.close();
+            }
+        }, RFB.connectTimeout);
+
     //console.log("<< init_ws");
     //console.log("<< init_ws");
 },
 },