YUKI Hiroshi
null+****@clear*****
Mon Apr 20 15:46:21 JST 2015
YUKI Hiroshi 2015-04-20 15:46:21 +0900 (Mon, 20 Apr 2015) New Revision: fd18f00782e94c627427a2b72de788026016600c https://github.com/droonga/express-droonga/commit/fd18f00782e94c627427a2b72de788026016600c Message: Use given timeout as a float Modified files: lib/droonga-protocol/connection.js Modified: lib/droonga-protocol/connection.js (+12 -6) =================================================================== --- lib/droonga-protocol/connection.js 2015-04-20 15:38:56 +0900 (4b970a5) +++ lib/droonga-protocol/connection.js 2015-04-20 15:46:21 +0900 (a693867) @@ -192,15 +192,15 @@ function getCurrentTime() { return isoStringWithMicroseconds; } -function toInteger(number) { +function toFloat(number) { if (!number) return 0; - var integer = parseInt(number); - if (isNaN(integer)) + var float = parseFloat(number); + if (isNaN(float)) return 0; - return integer; + return float; } Connection.prototype.emitMessage = function(type, body, callback, options) { @@ -265,11 +265,17 @@ Connection.prototype.emitMessage = function(type, body, callback, options) { this._logger.error(error); } }).bind(this)); - options.timeout = toInteger(options.timeout) || - DEFAULT_RESPONSE_TIMEOUT_SECONDS; + + if (typeof options.timeout == 'number') { + options.timeout = toFloat(options.timeout) + } + else { + options.timeout = DEFAULT_RESPONSE_TIMEOUT_SECONDS; + } if (options.timeout > -1) { var timeoutMilliseconds = options.timeout * ONE_SECOND_IN_MILLISECONDS; timeoutId = setTimeout((function() { + this._logger.trace('Connection timed out (message id: '+id+')'); this.removeAllListeners(event); if (sendingMessages) sendingMessages.callback = null; -------------- next part -------------- HTML����������������������������...다운로드