Merge pull request #135 from cmheia/wss-with-pwd

wss with password
This commit is contained in:
hamza zia 2015-04-19 15:06:33 +08:00
commit 8ff7145597
2 changed files with 12 additions and 1 deletions

View File

@ -37,6 +37,7 @@ function(_, JSON, name, utils, alerts) {
// when connection opens // when connection opens
onopen: function() { onopen: function() {
console.log('websocket initialized!!!');
sockRPC.initialized = true; sockRPC.initialized = true;
}, },
@ -93,7 +94,16 @@ function(_, JSON, name, utils, alerts) {
} }
try { try {
sockRPC.sock = new WebSocket(sockRPC.scheme + '://' + conf.host + ':' + conf.port + '/jsonrpc'); var authUrl = sockRPC.scheme + '://' + conf.host + ':' + conf.port + '/jsonrpc';
if (sockRPC.conf.auth && sockRPC.conf.auth.user && sockRPC.conf.auth.pass) {
authUrl = sockRPC.scheme + '://' +
sockRPC.conf.auth.user + ":" +
sockRPC.conf.auth.pass + "@" +
sockRPC.conf.host + ':' +
sockRPC.conf.port + '/jsonrpc';
}
sockRPC.sock = new WebSocket(authUrl);
sockRPC.sock.onopen = sockRPC.onopen; sockRPC.sock.onopen = sockRPC.onopen;
sockRPC.sock.onclose = sockRPC.onclose; sockRPC.sock.onclose = sockRPC.onclose;
sockRPC.sock.onerror = sockRPC.onerror; sockRPC.sock.onerror = sockRPC.onerror;

View File

@ -34,6 +34,7 @@ function(log, jsonRPC, sockRPC, alerts) {
opts.error = opts.error || angular.noop; opts.error = opts.error || angular.noop;
if (sockRPC.initialized) { if (sockRPC.initialized) {
console.log('calling sock rpc');
return sockRPC.invoke(opts); return sockRPC.invoke(opts);
} }
else { else {