Navigation Menu

Skip to content

Commit

Permalink
Convert timeout seconds to milliseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 20, 2015
1 parent b9033fa commit c3d0e6a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/droonga-protocol/connection.js
Expand Up @@ -37,9 +37,11 @@ var ERROR_GATEWAY_TIMEOUT =
Connection.ERROR_GATEWAY_TIMEOUT =
504;

var DEFAULT_RESPONSE_TIMEOUT =
Connection.DEFAULT_RESPONSE_TIMEOUT =
60 * 1000;
var ONE_SECOND_IN_MILLISECONDS = 1000;

var DEFAULT_RESPONSE_TIMEOUT_SECONDS =
Connection.DEFAULT_RESPONSE_TIMEOUT_SECONDS =
60;

function Connection(params) {
EventEmitter.call(this);
Expand Down Expand Up @@ -264,8 +266,9 @@ Connection.prototype.emitMessage = function(type, body, callback, options) {
}
}).bind(this));
options.timeout = toInteger(options.timeout) ||
DEFAULT_RESPONSE_TIMEOUT;
DEFAULT_RESPONSE_TIMEOUT_SECONDS;
if (options.timeout > -1) {
var timeoutMilliseconds = options.timeout * ONE_SECOND_IN_MILLISECONDS;
timeoutId = setTimeout((function() {
this.removeAllListeners(event);
if (sendingMessages)
Expand All @@ -279,7 +282,7 @@ Connection.prototype.emitMessage = function(type, body, callback, options) {
catch(error) {
this._logger.error(error);
}
}).bind(this), options.timeout);
}).bind(this), timeoutMilliseconds);
}
}
this._sendingMessages[id] = sendingMessages;
Expand Down

0 comments on commit c3d0e6a

Please sign in to comment.