diff options
author | Samuel <samuel@cendio.se> | 2015-02-26 12:41:46 +0100 |
---|---|---|
committer | Samuel <samuel@cendio.se> | 2015-02-26 12:41:46 +0100 |
commit | 4043d8bb12dbdd157146f6ff5a038ee645bd56b9 (patch) | |
tree | b9cba919e60d8780e9c6030e4f7f782c065cd6fd | |
parent | 2ec29db7524201bdb6e95bfc6d925bbf4aa55f34 (diff) | |
parent | e543525faa9cf0d683f41e183e89cd909f3dd229 (diff) | |
download | novnc-4043d8bb12dbdd157146f6ff5a038ee645bd56b9.tar.gz |
Merge pull request #458 from kanaka/bug/disconnect
Fix disconnect/reconnect issues
-rw-r--r-- | include/rfb.js | 1 | ||||
-rw-r--r-- | include/ui.js | 35 |
2 files changed, 26 insertions, 10 deletions
diff --git a/include/rfb.js b/include/rfb.js index 03d4b81..909112d 100644 --- a/include/rfb.js +++ b/include/rfb.js @@ -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) { diff --git a/include/ui.js b/include/ui.js index 8e13fee..e923ea8 100644 --- a/include/ui.js +++ b/include/ui.js @@ -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,10 +665,15 @@ 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; default: $D('connectButton').style.display = "none"; @@ -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() { |