diff options
author | Luke Fitzgerald <lw.fitzgerald@googlemail.com> | 2010-08-07 17:25:43 -0700 |
---|---|---|
committer | Luke Fitzgerald <lw.fitzgerald@googlemail.com> | 2010-08-07 17:25:43 -0700 |
commit | 7cd52847a519d2572fd5ceb34228969cab95f068 (patch) | |
tree | 29a05c719adbe364e6bc733049b7743e40ce8c0a | |
parent | 067633a608a7567168cadf96e1bd1d5907931430 (diff) |
Added pinging to keep connection open
-rw-r--r-- | plugins/Irc/ircmanager.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/plugins/Irc/ircmanager.php b/plugins/Irc/ircmanager.php index b99c7b2fe..bd6242a6a 100644 --- a/plugins/Irc/ircmanager.php +++ b/plugins/Irc/ircmanager.php @@ -31,6 +31,8 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } class IrcManager extends ImManager { protected $conn = null; + protected $lastPing = null; + protected $regchecks = array(); protected $regchecksLookup = array(); @@ -64,6 +66,18 @@ class IrcManager extends ImManager { } /** + * Idle processing for io manager's execution loop. + * Send keepalive pings to server. + * + * @return void + */ + public function idle($timeout = 0) { + if (empty($this->lastPing) || time() - $this->lastPing > 120) { + $this->send_ping(); + } + } + + /** * Process IRC events that have come in over the wire. * * @param resource $socket Socket to handle input on @@ -232,4 +246,14 @@ class IrcManager extends ImManager { return true; } + + /** + * Sends a ping + * + * @return void + */ + protected function send_ping() { + $this->lastPing = time(); + $this->conn->send('PING', $this->lastPing); + } } |