diff --git a/include/default_controls.js b/include/default_controls.js index c8424919..86d7fed8 100644 --- a/include/default_controls.js +++ b/include/default_controls.js @@ -117,7 +117,6 @@ load: function(target) { DC.rfb = RFB({'target': 'VNC_canvas', 'updateState': DC.updateState, 'clipboardReceive': DC.clipReceive}); - DC.rfb.init(); // Unfocus clipboard when over the VNC area $('VNC_screen').onmousemove = function () { diff --git a/include/rfb.js b/include/rfb.js index 4dfedf8a..13c7f6cf 100644 --- a/include/rfb.js +++ b/include/rfb.js @@ -215,7 +215,7 @@ RQshiftBytes = function(len) { // Setup routines // -// Create the public API interface +// Create the public API interface and initialize function constructor() { var i; Util.Debug(">> RFB.constructor"); @@ -234,6 +234,25 @@ function constructor() { updateState('fatal', "No working Canvas"); } + init_vars(); + + /* Check web-socket-js if no builtin WebSocket support */ + if (VNC_native_ws) { + Util.Info("Using native WebSockets"); + updateState('loaded', 'noVNC ready (using native WebSockets)'); + } else { + Util.Warn("Using web-socket-js flash bridge"); + if ((! Util.Flash) || + (Util.Flash.version < 9)) { + updateState('fatal', "WebSockets or Adobe Flash is required"); + } else if (document.location.href.substr(0, 7) === "file://") { + updateState('fatal', + "'file://' URL is incompatible with Adobe Flash"); + } else { + updateState('loaded', 'noVNC ready (using Flash WebSockets emulation)'); + } + } + Util.Debug("<< RFB.constructor"); return that; // Return the public API interface } @@ -1522,36 +1541,9 @@ clientCutText = function(text) { // Public API interface functions // -that.init = function () { - - init_vars(); - - /* Check web-socket-js if no builtin WebSocket support */ - if (VNC_native_ws) { - Util.Info("Using native WebSockets"); - updateState('loaded', 'noVNC ready (using native WebSockets)'); - } else { - Util.Warn("Using web-socket-js flash bridge"); - if ((! Util.Flash) || - (Util.Flash.version < 9)) { - updateState('fatal', "WebSockets or Adobe Flash is required"); - } else if (document.location.href.substr(0, 7) === "file://") { - updateState('fatal', - "'file://' URL is incompatible with Adobe Flash"); - } else { - updateState('loaded', 'noVNC ready (using Flash WebSockets emulation)'); - } - } -}; - that.connect = function(host, port, password) { //Util.Debug(">> connect"); - // Make sure we have done init checks - if ((rfb_state !== 'loaded') && (rfb_state !== 'fatal')) { - that.init(); - } - rfb_host = host; rfb_port = port; rfb_password = (password !== undefined) ? password : "";