YUKI Hiroshi
null+****@clear*****
Thu Jan 10 13:09:37 JST 2013
YUKI Hiroshi 2013-01-10 13:09:37 +0900 (Thu, 10 Jan 2013) New Revision: 8c3667b590af7a1768c24a9ce1b7c280c805a943 https://github.com/groonga/express-kotoumi/commit/8c3667b590af7a1768c24a9ce1b7c280c805a943 Log: Make receiver socket injectable Modified files: lib/backend-adaptor.js Modified: lib/backend-adaptor.js (+19 -7) =================================================================== --- lib/backend-adaptor.js 2012-12-28 18:07:28 +0900 (3c56ec6) +++ lib/backend-adaptor.js 2013-01-10 13:09:37 +0900 (6275f12) @@ -37,21 +37,33 @@ Connection.prototype = new EventEmitter(); Connection.prototype._init = function() { this._callbacks = {}; + this._initSender(); + this._initReceiver(); +}; +Connection.prototype._initSender = function() { this._sender = ( this._params.sender || fluent.createFluentSender(this._params.tag || DEFAULT_FLUENT_TAG, { host: this._params.host || DEFAULT_FLUENT_HOST, port: this._params.port || DEFAULT_FLUENT_PORT }) ); - this._socket = socketIo.listen(this._params.listenPort || DEFAULT_LISTEN_PORT); +}; - var self = this; - this._socket.sockets.on('connection', function(socket) { - socket.on((self._params.tag || DEFAULT_FLUENT_TAG)+ '.message', - self._handleMessage.bind(self)); - }); - this._socket.set('log level', 1); +Connection.prototype._initReceiver = function() { + this._receiver = ( + this._params.receiver || + socketIo.listen(this._params.listenPort || DEFAULT_LISTEN_PORT) + ); + + this._receiver.sockets.on( + 'connection', + (function(socket) { + socket.on((this._params.tag || DEFAULT_FLUENT_TAG)+ '.message', + this._handleMessage.bind(this)); + }).bind(this) + ); + this._receiver.set('log level', 1); }; Connection.prototype._handleMessage = function(message) { -------------- next part -------------- HTML����������������������������... Download