This repository has been archived by the owner on Feb 11, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 506
Refactor setupTimer to retimer #318
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d6a11bd
bring retimer in for keep-alive rescheduling
behrad 9d30779
Merge branch 'master' of https://github.com/adpdigital/mosca
behrad ae8ae00
Merge pull request #2 from mcollina/master
behrad 9b840e8
remove clearTimeout
behrad 5cefd0f
Merge branch 'master' of https://github.com/adpdigital/mosca
behrad 85d4b5c
fix js linting
behrad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,8 @@ OTHER DEALINGS IN THE SOFTWARE. | |
var async = require("async"), | ||
uuid = require("uuid"); | ||
|
||
var retimer = require('retimer'); | ||
|
||
function nop() {} | ||
|
||
/** | ||
|
@@ -151,10 +153,6 @@ Client.prototype._setup = function() { | |
* @api private | ||
*/ | ||
Client.prototype.setUpTimer = function() { | ||
if (this.timer) { | ||
clearTimeout(this.timer); | ||
} | ||
|
||
if (this.keepalive <= 0) { | ||
return; | ||
} | ||
|
@@ -164,10 +162,14 @@ Client.prototype.setUpTimer = function() { | |
|
||
this.logger.debug({ timeout: timeout }, "setting keepalive timeout"); | ||
|
||
this.timer = setTimeout(function() { | ||
that.logger.info("keepalive timeout"); | ||
that.onNonDisconnectClose(); | ||
}, timeout); | ||
if( this.timer ) { | ||
this.timer.reschedule( timeout ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and this one as |
||
} else { | ||
this.timer = retimer(function keepaliveTimeout() { | ||
that.logger.info("keepalive timeout"); | ||
that.onNonDisconnectClose(); | ||
}, timeout); | ||
} | ||
}; | ||
|
||
/** | ||
|
@@ -567,7 +569,7 @@ Client.prototype.close = function(callback) { | |
that.logger.debug("closing client"); | ||
|
||
if (this.timer) { | ||
clearTimeout(this.timer); | ||
this.timer.clear(); | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you write this one as
if (this.timer)
?