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

run() public method

Executes the event loop, which continues running until no active connections remain.
public run ( Phergie\Irc\ConnectionInterface | Phergie\Irc\ConnectionInterface[] $connections, boolean $autorun = true )
$connections Phergie\Irc\ConnectionInterface | Phergie\Irc\ConnectionInterface[]
$autorun boolean
    public function run($connections, $autorun = true)
    {
        if (!is_array($connections)) {
            $connections = array($connections);
        }
        $this->on('connect.error', function ($message, $connection, $logger) {
            $logger->error($message);
        });
        $this->emit('connect.before.all', array($connections));
        foreach ($connections as $connection) {
            $this->addConnection($connection);
        }
        $writes = array_map(function ($connection) {
            return $connection->getOption('write');
        }, $connections);
        $this->emit('connect.after.all', array($connections, $writes));
        if ($autorun) {
            $this->getLoop()->run();
        }
    }

Usage Example

Example #1
0
 /**
  * Connect to IRC and attach some event listeners
  */
 protected function run()
 {
     /**
      * Configure the IRC Client
      */
     $this->configure();
     /**
      * Read messages from the stream
      */
     $this->attachReadListener();
     /**
      * Attach the socket listener to write messages to the channel
      * when received from XMPP
      */
     $this->attachSocketReadTimer();
     /**
      * Attach the disconnect listener
      */
     $this->attachDisconnectListener();
     $this->client->run($this->connection);
 }
All Usage Examples Of Phergie\Irc\Client\React\Client::run