Integrate connect() in to constructor

An RFB object represents a single connection so it doesn't make
sense to have one without it trying to connect right away. Matches
the behaviour of other APIs, e.g. WebSocket.
This commit is contained in:
Pierre Ossman
2017-10-20 16:46:36 +02:00
parent 057b8fec7a
commit 2f4516f293
6 changed files with 134 additions and 213 deletions
+13 -26
View File
@@ -199,27 +199,6 @@ var UI = {
}
},
initRFB: function() {
try {
UI.rfb = new RFB(document.getElementById('noVNC_canvas'));
UI.rfb.onnotification = UI.notification;
UI.rfb.onupdatestate = UI.updateState;
UI.rfb.ondisconnected = UI.disconnectFinished;
UI.rfb.oncredentialsrequired = UI.credentials;
UI.rfb.oncapabilities = function () { UI.updatePowerButton(); UI.initialResize(); };
UI.rfb.onclipboard = UI.clipboardReceive;
UI.rfb.onbell = UI.bell;
UI.rfb.onfbresize = UI.updateSessionSize;
UI.rfb.ondesktopname = UI.updateDesktopName;
return true;
} catch (exc) {
var msg = "Unable to create RFB client -- " + exc;
Log.Error(msg);
UI.showStatus(msg, 'error');
return false;
}
},
/* ------^-------
* /INIT
* ==============
@@ -1042,8 +1021,6 @@ var UI = {
return;
}
if (!UI.initRFB()) return;
UI.closeAllPanels();
UI.closeConnectPanel();
@@ -1059,9 +1036,19 @@ var UI = {
}
url += '/' + path;
UI.rfb.connect(url, { shared: UI.getSetting('shared'),
repeaterID: UI.getSetting('repeaterID'),
credentials: { password: password } });
UI.rfb = new RFB(document.getElementById('noVNC_canvas'), url,
{ shared: UI.getSetting('shared'),
repeaterID: UI.getSetting('repeaterID'),
credentials: { password: password } });
UI.rfb.onnotification = UI.notification;
UI.rfb.onupdatestate = UI.updateState;
UI.rfb.ondisconnected = UI.disconnectFinished;
UI.rfb.oncredentialsrequired = UI.credentials;
UI.rfb.oncapabilities = function () { UI.updatePowerButton(); UI.initialResize(); };
UI.rfb.onclipboard = UI.clipboardReceive;
UI.rfb.onbell = UI.bell;
UI.rfb.onfbresize = UI.updateSessionSize;
UI.rfb.ondesktopname = UI.updateDesktopName;
},
disconnect: function() {