mirror of
https://github.com/vale981/autossh
synced 2025-03-05 09:21:40 -05:00
rename debounce to poll
This commit is contained in:
parent
7e0ad0c549
commit
73a18b903d
1 changed files with 15 additions and 12 deletions
27
index.js
27
index.js
|
@ -38,9 +38,9 @@ var AutoSSH = function (_EventEmitter) {
|
||||||
_this.remotePort = conf.remotePort;
|
_this.remotePort = conf.remotePort;
|
||||||
_this.localPort = conf.localPort || 'auto';
|
_this.localPort = conf.localPort || 'auto';
|
||||||
|
|
||||||
_this.debounceCount = 0;
|
_this.pollCount = 0;
|
||||||
_this.maxDebounceCount = 25;
|
_this.maxPollCount = 25;
|
||||||
_this.debounceTimeout = 50;
|
_this.pollTimeout = 50;
|
||||||
|
|
||||||
setImmediate(function () {
|
setImmediate(function () {
|
||||||
var confErrors = _this.getConfErrors(conf);
|
var confErrors = _this.getConfErrors(conf);
|
||||||
|
@ -58,7 +58,7 @@ var AutoSSH = function (_EventEmitter) {
|
||||||
_this.localPort = freePort;
|
_this.localPort = freePort;
|
||||||
|
|
||||||
_this.execTunnel(function () {
|
_this.execTunnel(function () {
|
||||||
_this.debounceConnection(function () {
|
_this.pollConnection(function () {
|
||||||
_this.emit('connect', {
|
_this.emit('connect', {
|
||||||
kill: _this.kill,
|
kill: _this.kill,
|
||||||
pid: _this.currentProcess.pid,
|
pid: _this.currentProcess.pid,
|
||||||
|
@ -79,22 +79,21 @@ var AutoSSH = function (_EventEmitter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
_createClass(AutoSSH, [{
|
_createClass(AutoSSH, [{
|
||||||
key: 'debounceConnection',
|
key: 'pollConnection',
|
||||||
value: function debounceConnection(cb) {
|
value: function pollConnection(cb) {
|
||||||
var _this2 = this;
|
var _this2 = this;
|
||||||
|
|
||||||
if (this.debounceCount >= this.maxDebounceCount) {
|
if (this.pollCount >= this.maxPollCount) {
|
||||||
this.emit('error', 'Max debounce count reached. Aborting...');
|
this.emit('error', 'Max poll count reached. Aborting...');
|
||||||
return this.kill();
|
return this.kill();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isConnectionEstablished(function (result) {
|
this.isConnectionEstablished(function (result) {
|
||||||
if (result) return cb();
|
if (result) return cb();
|
||||||
console.log('Not Ready... Debounce!!!');
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
_this2.debounceCount++;
|
_this2.pollCount++;
|
||||||
_this2.debounceConnection(cb);
|
_this2.pollConnection(cb);
|
||||||
}, _this2.debounceTimeout);
|
}, _this2.pollTimeout);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
@ -171,6 +170,10 @@ var AutoSSH = function (_EventEmitter) {
|
||||||
return AutoSSH;
|
return AutoSSH;
|
||||||
}(_events.EventEmitter);
|
}(_events.EventEmitter);
|
||||||
|
|
||||||
|
/* Export
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
module.exports = function (conf) {
|
module.exports = function (conf) {
|
||||||
var autossh = new AutoSSH(conf);
|
var autossh = new AutoSSH(conf);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue