[Groonga-commit] droonga/express-droonga at 5889eaf [master] Ignore published messages for other subscribers by HTTP streaming connection

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Jan 9 11:29:43 JST 2014


YUKI Hiroshi	2014-01-09 11:29:43 +0900 (Thu, 09 Jan 2014)

  New Revision: 5889eafb66db599374d69e4fc0c3b739f0825779
  https://github.com/droonga/express-droonga/commit/5889eafb66db599374d69e4fc0c3b739f0825779

  Message:
    Ignore published messages for other subscribers by HTTP streaming connection

  Modified files:
    lib/adapter/command.js

  Modified: lib/adapter/command.js (+9 -5)
===================================================================
--- lib/adapter/command.js    2014-01-08 16:55:00 +0900 (06cad2f)
+++ lib/adapter/command.js    2014-01-09 11:29:43 +0900 (5a244a7)
@@ -159,11 +159,6 @@ HTTPStreaming.extend = function(targetClass) {
       'Transfer-Encoding': 'chunked'
     });
 
-    var onPublish = function(message) {
-      response.write(JSON.stringify(message.body) + self.delimiter);
-    };
-    connection.on(this.messageType, onPublish);
-
     var subscriptionMessage = this.createSubscription(request);
     if (!subscriptionMessage.route) {
       var route = connection.routeToSelf;
@@ -174,6 +169,15 @@ HTTPStreaming.extend = function(targetClass) {
       subscriptionMessage.subscriber = subscriberID;
     }
 
+    var onPublish = function(message) {
+      var subscriberIds = message.to;
+      if (!Array.isArray(subscriberIds))
+        subscriberIds = [subscriberIds];
+      if (subscriberIds.indexOf(subscriptionMessage.subscriber) > -1)
+        response.write(JSON.stringify(message.body) + self.delimiter);
+    };
+    connection.on(this.messageType, onPublish);
+
     var subscribe = function() {
       connection.emit(self.subscription, subscriptionMessage);
     };
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index