vis.js is a dynamic, browser-based visualization library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.6 KiB

  1. function timelineAgent(id, proxyAddress) {
  2. // execute super constructor
  3. eve.Agent.call(this, id);
  4. this.proxyAddress = proxyAddress;
  5. this.eventTypes = {};
  6. this.timelineEvents = [];
  7. this.timelineClient = undefined;
  8. this.inputClient = undefined;
  9. // extend the agent with RPC functionality
  10. this.rpc = this.loadModule('rpc', this.rpcFunctions, {timeout:2000}); // option 1
  11. // connect to all transports provided by the system
  12. this.connect(eve.system.transports.getAll());
  13. }
  14. // extend the eve.Agent prototype
  15. timelineAgent.prototype = Object.create(eve.Agent.prototype);
  16. timelineAgent.prototype.constructor = timelineAgent;
  17. timelineAgent.prototype.rpcFunctions = {};
  18. timelineAgent.prototype.rpcFunctions.close = function() {
  19. sessionClosed();
  20. };
  21. timelineAgent.prototype.connectToProxy = function() {
  22. this.rpc.request(this.proxyAddress, {method:'setTimelineClient',params:{}}).done(function () {
  23. connected = true;
  24. });
  25. };
  26. timelineAgent.prototype.rpcFunctions.addTimelineEvent = function(params,sender) {
  27. addToDataset(params.item);
  28. };
  29. timelineAgent.prototype.rpcFunctions.resetTimelineEvents = function(params,sender) {
  30. clearDataset();
  31. };
  32. timelineAgent.prototype.wakeProxy = function(httpAddress) {
  33. this.rpc.request(httpAddress, {method:'wakeUp',params:{}}).done();
  34. };
  35. timelineAgent.prototype.getTimelineEvents = function (params, sender) {
  36. var me = this;
  37. return new Promise(function(resolve,reject) {
  38. me.rpc.request(me.proxyAddress, {method: 'getTimelineEvents', params: {}})
  39. .then(function (reply) {
  40. resolve(reply);
  41. })
  42. .catch(function(err) {reject(err);});
  43. })
  44. };