1. Rune Halvorsen
  2. dragonfly-stp-1-event-branch

Commits

Rune Halvorsen  committed cd4ed2e

Switched to using message based API for http logger

  • Participants
  • Parent commits 53e880f
  • Branches default

Comments (0)

Files changed (2)

File src/build-application/build_http_logger_2_0.js

View file
   var service_interface = window.services['http-logger'];
   if(service_interface)
   {
-    (new namespace.ParseMessages()).bind(service_interface);
+    new namespace.HTTPLoggerService();
     window.HTTPLoggerData = new namespace.HTTPLoggerData();
     namespace.RequestListView.prototype = ViewBase;
     new namespace.RequestListView('request_list', ui_strings.M_VIEW_LABEL_REQUEST_LOG, 'scroll');

File src/http-logger/httplogger_service.js

View file
   * @constructor
   * @extends ServiceBase
   */
-cls.HttpLogger["2.0"].ParseMessages = function(name)
+cls.HttpLogger["2.0"].HTTPLoggerService = function(name)
 {
-    var self = this;
     var view = "http_logger";
 
     /**
      * }
      *
      */
-    this.parseRequest = function(status, message)
+    this.parseRequest = function(message)
     {
         /*
         const
           "request-id": message[0],
           "window-id": message[1],
           time: Math.round(parseFloat(message[2])),
-          raw: message[3],
+          raw: message[3]
         });
     };
 
      * }
      *
      */
-    this.parseResponse = function(status, message)
+    this.parseResponse = function(message)
     {
         /*
         const
         return headers;
     };
 
-  this.bind = function(http_logger)
+  this.onRequest = function(msg)
   {
-    var
-    parse_request = this.parseRequest.bind(this),
-    parse_response = self.parseResponse.bind(this);
+    window.HTTPLoggerData.addRequest(this.parseRequest(msg));
+  };
 
-    http_logger.onRequest = function(status, msg)
-    {
-      window.HTTPLoggerData.addRequest(parse_request(status, msg));
-    };
-    http_logger.onResponse = function(status, msg)
-    {
-      window.HTTPLoggerData.addResponse(parse_response(status, msg));
-    };
+  this.onResponse = function(msg)
+  {
+    window.HTTPLoggerData.addResponse(this.parseResponse(msg));
   };
+
+  this.init = function()
+  {
+    var service = window.services['http-logger'];
+    service.addListener("request", this.onRequest.bind(this));
+    service.addListener("response", this.onResponse.bind(this));
+  };
+
+  this.init();
 };