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

addConnection() public method

Emits connect.before.each and connect.after.each events before and after connection attempts are established, respectively. Emits a connect.error event if a connection attempt fails.
public addConnection ( Phergie\Irc\ConnectionInterface $connection )
$connection Phergie\Irc\ConnectionInterface Metadata for connection to establish
    public function addConnection(ConnectionInterface $connection)
    {
        $this->emit('connect.before.each', array($connection));
        if ($this->getTransport($connection) === 'ssl') {
            $this->addSecureConnection($connection);
        } else {
            $this->addUnsecuredConnection($connection);
        }
    }

Usage Example

Example #1
0
 /**
  * Watches for a DC and reconnects to IRC
  */
 private function attachDisconnectListener()
 {
     $this->client->on('connect.end', function (Connection $connection, LoggerInterface $logger) {
         /**
          * @var Connection $connection
          * @var Client     $client
          */
         $logger->debug('Connection to ' . $connection->getServerHostname() . ' lost, attempting to reconnect');
         $this->client->addConnection($connection);
     });
 }
All Usage Examples Of Phergie\Irc\Client\React\Client::addConnection