[Groonga-commit] droonga/express-droonga at 6719106 [master] Simplify translation mechanism for published messages

アーカイブの一覧に戻る

YUKI Hiroshi null+****@clear*****
Thu Jan 9 12:06:20 JST 2014


YUKI Hiroshi	2014-01-09 12:06:20 +0900 (Thu, 09 Jan 2014)

  New Revision: 67191062874bca83c816e9e5100562e5ffb3c878
  https://github.com/droonga/express-droonga/commit/67191062874bca83c816e9e5100562e5ffb3c878

  Message:
    Simplify translation mechanism for published messages

  Modified files:
    lib/adapter/command.js

  Modified: lib/adapter/command.js (+9 -7)
===================================================================
--- lib/adapter/command.js    2014-01-09 12:01:49 +0900 (a6ad73b)
+++ lib/adapter/command.js    2014-01-09 12:06:20 +0900 (b14c2b3)
@@ -148,12 +148,12 @@ HTTPStreaming.extend = function(targetClass) {
   Object.defineProperty(targetClass.prototype, 'createSubscription', {
     get: function() { return this._options.createSubscription; }
   });
-  Object.defineProperty(targetClass.prototype, 'onPublish', {
-    get: function() { return this._options.onPublish || this._onPublish; }
+  Object.defineProperty(targetClass.prototype, 'translate', {
+    get: function() { return this._options.translate || this._translate; }
   });
-  if (!targetClass.prototype._onPublish)
-    targetClass.prototype._onPublish = function(message, response) {
-      response.write(JSON.stringify(message) + this.delimiter);
+  if (!targetClass.prototype._translate)
+    targetClass.prototype._translate = function(message) {
+      return message;
     };
 
   var connectionsCount = 0;
@@ -180,8 +180,10 @@ HTTPStreaming.extend = function(targetClass) {
       var subscriberIds = message.to;
       if (!Array.isArray(subscriberIds))
         subscriberIds = [subscriberIds];
-      if (subscriberIds.indexOf(subscriptionMessage.subscriber) > -1)
-        self.onPublish.call(this, message.body, response);
+      if (subscriberIds.indexOf(subscriptionMessage.subscriber) < 0)
+        return;
+      var deliveredMessage = self.translate.call(this, message.body);
+      response.write(JSON.stringify(deliveredMessage) + self.delimiter);
     };
     connection.on(this.messageType, onPublish);
 
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る