summaryrefslogtreecommitdiffstats
path: root/static/js/dbusWebsocketFactory.js
blob: 716f2df7713e80b6ac21bf7b76cc869dd9d86786 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
angular.module('bmcApp').factory('dbusWebsocketService', [
  '$location',
  function($location) {
    return {
      start: function(dbus_namespace, callback) {
        var url = '/dbus_monitor?path_namespace=' + dbus_namespace;
        var host = $location.host();
        var port = 18080;
        var protocol = 'wss://';
        if ($location.protocol() === 'http') {
          protocol = 'ws://';
        }
        var websocket = new WebSocket(protocol + host + ':' + port + url);
        websocket.onopen = function() {};
        websocket.onclose = function() {};
        websocket.onmessage = function(evt) { callback(evt); };
      }
    }
  }
]);
OpenPOWER on IntegriCloud