/** * Returns a callback for when a connection is terminated, whether * explicitly by the bot or server or as a result of loss of connectivity. * * @param \Phergie\Irc\Client\React\ReadStream $read Read stream for this * connection * @param \Phergie\Irc\Client\React\WriteStream $write Write stream for this * connection * @param \Phergie\Irc\ConnectionInterface $connection Terminated connection * @param \React\EventLoop\Timer\TimerInterface $timer Timer used to handle * asynchronously queued events on the connection, which must be * cancelled * @return callable */ protected function getEndCallback(ReadStream $read, WriteStream $write, ConnectionInterface $connection, TimerInterface $timer) { $logger = $this->getLogger(); return function () use($read, $write, $connection, $timer, $logger) { $this->removeActiveConnection($connection); $this->emit('connect.end', array($connection, $logger)); $this->cancelTimer($timer); $connection->clearData(); $read->close(); $write->close(); }; }
/** * Tests getParser(). */ public function testGetParser() { $read = new ReadStream(); $this->assertInstanceOf('\\Phergie\\Irc\\ParserInterface', $read->getParser()); }