diff options
author | elioat <hi@eli.li> | 2023-06-19 12:27:59 -0400 |
---|---|---|
committer | elioat <hi@eli.li> | 2023-06-19 12:27:59 -0400 |
commit | 1cbdbcff09387f1185e40fa48fd3801e54e5ba86 (patch) | |
tree | d8ab8872a81c0656c62334fb43f4bc07db8aa807 /js/blotbotboot/node_modules/irc/lib/cycling_ping_timer.js | |
parent | 00761c368216e401eb5b17a677ae51db643d818b (diff) | |
download | tour-1cbdbcff09387f1185e40fa48fd3801e54e5ba86.tar.gz |
Removed node_modules folder because I am an idiot
Diffstat (limited to 'js/blotbotboot/node_modules/irc/lib/cycling_ping_timer.js')
-rw-r--r-- | js/blotbotboot/node_modules/irc/lib/cycling_ping_timer.js | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/js/blotbotboot/node_modules/irc/lib/cycling_ping_timer.js b/js/blotbotboot/node_modules/irc/lib/cycling_ping_timer.js deleted file mode 100644 index 1466df6..0000000 --- a/js/blotbotboot/node_modules/irc/lib/cycling_ping_timer.js +++ /dev/null @@ -1,87 +0,0 @@ -'use strict'; - -var util = require('util'); -var EventEmitter = require('events').EventEmitter; - -/** - * This class encapsulates the ping timeout functionality. When enough - * silence (lack of server-sent activity) time passes, an object of this type - * will emit a 'wantPing' event, indicating you should send a PING message - * to the server in order to get some signs of life from it. If enough - * time passes after that (i.e. server does not respond to PING), then - * an object of this type will emit a 'pingTimeout' event. - * - * To start the gears turning, call start() on an instance of this class To - * put it in the 'started' state. - * - * When server-side activity occurs, call notifyOfActivity() on the object. - * - * When a pingTimeout occurs, the object will go into the 'stopped' state. - */ -var ctr = 0; - -function CyclingPingTimer(client) { - var timerNumber = ctr++; - var started = false; - var self = this; - - // Only one of these two should be non-null at any given time. - var loopingTimeout = null; - var pingWaitTimeout = null; - - // conditionally log debug messages - function debug(msg) { - if (client.opt.debug) { - console.error('CyclingPingTimer ' + timerNumber + ': ' + msg); - } - } - - // set up EventEmitter functionality - EventEmitter.call(self); - - self.on('wantPing', function() { - debug('server silent for too long, let\'s send a PING'); - pingWaitTimeout = setTimeout(function() { - self.stop(); - debug('ping timeout!'); - self.emit('pingTimeout'); - }, client.opt.millisecondsBeforePingTimeout); - }); - - self.notifyOfActivity = function() { - if (started) { - self.stop(); - self.start(); - } - }; - - self.stop = function() { - if (!started) { - return; - } - started = false; - - clearTimeout(loopingTimeout); - clearTimeout(pingWaitTimeout); - - loopingTimeout = null; - pingWaitTimeout = null; - }; - - self.start = function() { - if (started) { - debug('can\'t start, not stopped!'); - return; - } - started = true; - - loopingTimeout = setTimeout(function() { - loopingTimeout = null; - self.emit('wantPing'); - }, client.opt.millisecondsOfSilenceBeforePingSent); - }; -} - -util.inherits(CyclingPingTimer, EventEmitter); - -module.exports = CyclingPingTimer; |