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

configureStreams() protected method

Configure streams to handle messages received from and sent to the server.
protected configureStreams ( Phergie\Irc\ConnectionInterface $connection, React\Stream\DuplexStreamInterface $stream, Phergie\Irc\Client\React\WriteStream $write )
$connection Phergie\Irc\ConnectionInterface Metadata for the connection over which messages are being exchanged
$stream React\Stream\DuplexStreamInterface Stream representing the connection to the server
$write Phergie\Irc\Client\React\WriteStream Stream used to send events to the server
    protected function configureStreams(ConnectionInterface $connection, DuplexStreamInterface $stream, WriteStream $write)
    {
        $timer = $this->addPeriodicTimer($this->getTickInterval(), $this->getTickCallback($write, $connection));
        $read = $this->getReadStream($connection);
        $write->pipe($stream)->pipe($read);
        $read->on('irc.received', $this->getReadCallback($write, $connection));
        $write->on('data', $this->getWriteCallback($write, $connection));
        $end = array($stream, 'end');
        $read->on('end', $end);
        $write->on('end', $end);
        $stream->on('end', $this->getEndCallback($read, $write, $connection, $timer));
        $error = $this->getErrorCallback($connection);
        $read->on('error', $error);
        $write->on('error', $error);
    }