]> git.proxmox.com Git - mirror_novnc.git/commitdiff
Fix disconnect/reconnect issues
authorSolly Ross <sross@redhat.com>
Fri, 20 Feb 2015 22:27:27 +0000 (17:27 -0500)
committerSolly Ross <sross@redhat.com>
Wed, 25 Feb 2015 16:01:18 +0000 (11:01 -0500)
Commit 155d78b39933a396d2555376f4e70f976c30b86d prevented reconnections
from working properly.  This fixes that by creating a new RFB object
after disconnecting or failing.

Furthermore, this ensures that a new connection cannot be opened util
we've actually disconnected (either by timer or by receiving a `close`
event).

Closes #452

include/rfb.js
include/ui.js

index 03d4b8166b45df1d6d5f4902bafe28d7992ca3e1..909112d58fab32361968272008a02963ba40333e 100644 (file)
@@ -482,6 +482,7 @@ var RFB;
                 Util.Debug("Clearing disconnect timer");
                 clearTimeout(this._disconnTimer);
                 this._disconnTimer = null;
+                this._sock.off('close');  // make sure we don't get a double event
             }
 
             switch (state) {
index 8e13fee047bb6bea896ff69f14a700f41be56684..e923ea8c6a6669f19d5c9b296cb1bcad7884cd20 100644 (file)
@@ -110,13 +110,7 @@ var UI;
             UI.initSetting('path', 'websockify');
             UI.initSetting('repeaterID', '');
 
-            UI.rfb = new RFB({'target': $D('noVNC_canvas'),
-                              'onUpdateState': UI.updateState,
-                              'onXvpInit': UI.updateXvpVisualState,
-                              'onClipboard': UI.clipReceive,
-                              'onFBUComplete': UI.FBUComplete,
-                              'onFBResize': UI.updateViewDragButton,
-                              'onDesktopName': UI.updateDocumentTitle});
+            UI.initRFB();
 
             var autoconnect = WebUtil.getQueryVar('autoconnect', false);
             if (autoconnect === 'true' || autoconnect == '1') {
@@ -192,6 +186,16 @@ var UI;
             }
         },
 
+        initRFB: function () {
+            UI.rfb = new RFB({'target': $D('noVNC_canvas'),
+                              'onUpdateState': UI.updateState,
+                              'onXvpInit': UI.updateXvpVisualState,
+                              'onClipboard': UI.clipReceive,
+                              'onFBUComplete': UI.FBUComplete,
+                              'onFBResize': UI.updateViewDragButton,
+                              'onDesktopName': UI.updateDocumentTitle});
+        },
+
         addMouseHandlers: function() {
             // Setup interface handlers that can't be inline
             $D("noVNC_view_drag_button").onclick = UI.setViewDrag;
@@ -602,6 +606,13 @@ var UI;
                     break;
             }
 
+            switch (state) {
+                case 'fatal':
+                case 'failed':
+                case 'disconnected':
+                    UI.initRFB();
+            }
+
             if (typeof(msg) !== 'undefined') {
                 $D('noVNC-control-bar').setAttribute("class", klass);
                 $D('noVNC_status').innerHTML = msg;
@@ -654,8 +665,13 @@ var UI;
             switch (UI.rfb_state) {
                 case 'fatal':
                 case 'failed':
-                case 'loaded':
                 case 'disconnected':
+                    $D('connectButton').style.display = "";
+                    $D('disconnectButton').style.display = "none";
+                    UI.connSettingsOpen = false;
+                    UI.toggleConnectPanel();
+                    break;
+                case 'loaded':
                     $D('connectButton').style.display = "";
                     $D('disconnectButton').style.display = "none";
                     break;
@@ -736,8 +752,7 @@ var UI;
             UI.rfb.set_onFBUComplete(UI.FBUComplete);
 
             $D('noVNC_logo').style.display = "block";
-            UI.connSettingsOpen = false;
-            UI.toggleConnectPanel();
+            // Don't display the connection settings until we're actually disconnected
         },
 
         displayBlur: function() {