Phergie\Irc\Client\React\Client::getEndCallback PHP Method

getEndCallback() protected method

Returns a callback for when a connection is terminated, whether explicitly by the bot or server or as a result of loss of connectivity.
protected getEndCallback ( Phergie\Irc\Client\React\ReadStream $read, Phergie\Irc\Client\React\WriteStream $write, Phergie\Irc\ConnectionInterface $connection, React\EventLoop\Timer\TimerInterface $timer ) : callable
$read Phergie\Irc\Client\React\ReadStream Read stream for this connection
$write Phergie\Irc\Client\React\WriteStream Write stream for this connection
$connection Phergie\Irc\ConnectionInterface Terminated connection
$timer React\EventLoop\Timer\TimerInterface 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();
        };
    }