This commit is contained in:
Jo De Boeck 2014-02-24 17:52:51 +02:00
commit 092206b406
3 changed files with 21 additions and 3 deletions

View File

@ -40,6 +40,7 @@ var that = {}, // Public API methods
rfb_port = 5900,
rfb_password = '',
rfb_path = '',
rfb_queryargs = '',
rfb_state = 'disconnected',
rfb_version = 0,
@ -305,6 +306,12 @@ function connect() {
}
uri += rfb_host + ":" + rfb_port + "/" + rfb_path;
}
if (rfb_queryargs != null) {
var querystr = WebUtil.objToQueryString(rfb_queryargs);
if (querystr != "") {
uri += "?" + querystr;
}
}
Util.Info("connecting to " + uri);
// TODO: make protocols a configurable
ws.open(uri, conf.wsProtocols);
@ -1880,13 +1887,14 @@ clientCutText = function(text) {
// Public API interface functions
//
that.connect = function(host, port, password, path) {
that.connect = function(host, port, password, path, queryargs) {
//Util.Debug(">> connect");
rfb_host = host;
rfb_port = port;
rfb_password = (password !== undefined) ? password : "";
rfb_path = (path !== undefined) ? path : "";
rfb_queryargs = (queryargs !== undefined) ? queryargs : null;
if ((!rfb_host) || (!rfb_port)) {
return fail("Must set host and port");

View File

@ -219,3 +219,12 @@ WebUtil.selectStylesheet = function(sheet) {
}
return sheet;
};
// Method to help create query string from simple map
WebUtil.objToQueryString = function(obj) {
var str = [];
for(var p in obj) {
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
}
return str.join("&");
}

View File

@ -149,7 +149,7 @@
}
window.onscriptsload = function () {
var host, port, password, path, token;
var host, port, password, path, token, queryargs;
$D('sendCtrlAltDelButton').style.display = "inline";
$D('sendCtrlAltDelButton').onclick = sendCtrlAltDel;
@ -178,6 +178,7 @@
// This is used by nova-novncproxy.
token = WebUtil.getQueryVar('token', null);
if (token) {
queryargs = {token: token};
WebUtil.createCookie('token', token, 1)
}
@ -201,7 +202,7 @@
'updateState': updateState,
'onXvpInit': xvpInit,
'onPasswordRequired': passwordRequired});
rfb.connect(host, port, password, path);
rfb.connect(host, port, password, path, queryargs);
};
</script>