Reverted changes to Prehash.

This commit is contained in:
DariusIII
2014-04-21 13:48:05 +02:00
parent b2497df280
commit 67248fdec3
14 changed files with 6213 additions and 338 deletions
+36
View File
@@ -0,0 +1,36 @@
<?php
class Net_SmartIRC_module_PingFix
{
public $name = 'PingFix';
public $version = '1.0';
public $description = 'An active-pinging system to keep the bot from dropping the connection';
public $author = 'Garrett W.';
public $license = 'LGPL';
private $irc;
private $thid;
function __construct(&$irc)
{
$this->irc = $irc;
$this->thid = $this->irc->registerTimehandler(
$this->irc->_rxtimeout / 8 * 1000, $this, 'pingCheck'
);
}
function __destruct()
{
$this->irc->unregisterTimeid($this->thid);
}
function pingCheck()
{
if (time() - $this->irc->_lastrx > $this->irc->_rxtimeout) {
$this->irc->reconnect();
$this->irc->_lastrx = time();
} elseif (time() - $this->irc->_lastrx > $this->irc->_rxtimeout / 3) {
$this->irc->_send('PING ' . $this->irc->_address, SMARTIRC_CRITICAL);
}
}
}