GUI -- Added ability to define an alternate port for WS - used to connect to mock web-socket server. Topo view can use query string '?wsport=8123' for example.
Change-Id: Ie34d557b9580d58239380010e8d58233998a78ca
diff --git a/web/gui/src/main/webapp/app/fw/remote/websocket.js b/web/gui/src/main/webapp/app/fw/remote/websocket.js
index de7b076..bdd1e3c 100644
--- a/web/gui/src/main/webapp/app/fw/remote/websocket.js
+++ b/web/gui/src/main/webapp/app/fw/remote/websocket.js
@@ -23,15 +23,17 @@
var fs;
angular.module('onosRemote')
- .factory('WebSocketService', ['$location', 'UrlFnService', 'FnService',
- function ($loc, ufs, _fs_) {
+ .factory('WebSocketService',
+ ['$log', '$location', 'UrlFnService', 'FnService',
+
+ function ($log, $loc, ufs, _fs_) {
fs = _fs_;
// creates a web socket for the given path, returning a "handle".
- // cb is the callbacks block.
- function createWebSocket(path, cb) {
- //var fullUrl = ufs.wsUrl(path),
- var fullUrl = 'ws://localhost:8123/foo',
+ // opts contains the event handler callbacks.
+ function createWebSocket(path, opts) {
+ var wsport = opts && opts.wsport,
+ fullUrl = ufs.wsUrl(path, wsport),
ws = new WebSocket(fullUrl),
api = {
meta: { path: fullUrl, ws: ws },
@@ -39,9 +41,11 @@
close: close
};
- ws.onopen = (cb && cb.onOpen) || null;
- ws.onmessage = (cb && cb.onMessage) || null;
- ws.onclose = (cb && cb.onClose) || null;
+ $log.debug('Attempting to open websocket to: ' + fullUrl);
+
+ ws.onopen = (opts && opts.onOpen) || null;
+ ws.onmessage = (opts && opts.onMessage) || null;
+ ws.onclose = (opts && opts.onClose) || null;
function send(msg) {
if (msg) {