From 53ce35102ea7192f8607ea8ac887a10def446897 Mon Sep 17 00:00:00 2001 From: cmheia Date: Sun, 5 Apr 2015 03:36:04 +0800 Subject: [PATCH] wss with password add support for wss://user:passwd@host:port/jsonrpc --- js/services/rpc/sockcall.js | 12 +++++++++++- js/services/rpc/syscall.js | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/js/services/rpc/sockcall.js b/js/services/rpc/sockcall.js index 2e144a6..9e43fca 100644 --- a/js/services/rpc/sockcall.js +++ b/js/services/rpc/sockcall.js @@ -37,6 +37,7 @@ function(_, JSON, name, utils, alerts) { // when connection opens onopen: function() { + console.log('websocket initialized!!!'); sockRPC.initialized = true; }, @@ -93,7 +94,16 @@ function(_, JSON, name, utils, alerts) { } 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.onclose = sockRPC.onclose; sockRPC.sock.onerror = sockRPC.onerror; diff --git a/js/services/rpc/syscall.js b/js/services/rpc/syscall.js index fe0ec36..a7a6eca 100644 --- a/js/services/rpc/syscall.js +++ b/js/services/rpc/syscall.js @@ -34,6 +34,7 @@ function(log, jsonRPC, sockRPC, alerts) { opts.error = opts.error || angular.noop; if (sockRPC.initialized) { + console.log('calling sock rpc'); return sockRPC.invoke(opts); } else {