YUKI Hiroshi
null+****@clear*****
Thu Jan 9 12:01:49 JST 2014
YUKI Hiroshi 2014-01-09 12:01:49 +0900 (Thu, 09 Jan 2014) New Revision: b44411f9b19d08676b3af3ed5a10910baf26230a https://github.com/droonga/express-droonga/commit/b44411f9b19d08676b3af3ed5a10910baf26230a Message: Make published messages translatable Modified files: lib/adapter/command.js Modified: lib/adapter/command.js (+8 -1) =================================================================== --- lib/adapter/command.js 2014-01-09 11:30:55 +0900 (5a244a7) +++ lib/adapter/command.js 2014-01-09 12:01:49 +0900 (a6ad73b) @@ -148,6 +148,13 @@ 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; } + }); + if (!targetClass.prototype._onPublish) + targetClass.prototype._onPublish = function(message, response) { + response.write(JSON.stringify(message) + this.delimiter); + }; var connectionsCount = 0; targetClass.prototype.onHandle = function(request, response, connection) { @@ -174,7 +181,7 @@ HTTPStreaming.extend = function(targetClass) { if (!Array.isArray(subscriberIds)) subscriberIds = [subscriberIds]; if (subscriberIds.indexOf(subscriptionMessage.subscriber) > -1) - response.write(JSON.stringify(message.body) + self.delimiter); + self.onPublish.call(this, message.body, response); }; connection.on(this.messageType, onPublish); -------------- next part -------------- HTML����������������������������...Download