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
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);
 }
 /**
  * Tests run() with a connection configured to use the SSL transport.
  */
 public function testRunWithConnectionUsingSslTransport()
 {
     $loop = $this->getMockLoop();
     $connection = $this->getMockConnectionForAddConnection();
     $connections = array($connection);
     $writeStream = $this->getMockWriteStream();
     $writeStreams = array($writeStream);
     Phake::when($connection)->getOption('write')->thenReturn($writeStream);
     Phake::when($connection)->getOption('transport')->thenReturn('ssl');
     Phake::when($this->client)->getWriteStream($connection)->thenReturn($writeStream);
     Phake::when($this->client)->getLoop()->thenReturn($loop);
     $this->client->setLogger($this->getMockLogger());
     $this->client->setResolver($this->getMockResolver('null'));
     $this->client->run($connection);
     Phake::inOrder(Phake::verify($this->client)->emit('connect.before.all', array($connections)), Phake::verify($this->client)->addConnection($connection), Phake::verify($this->client)->emit('connect.after.all', array($connections, $writeStreams)), Phake::verify($loop, Phake::times(1))->run());
 }
Example #3
0
 /**
  * @param ConnectionInterface[] $connections
  * @return void
  */
 public function run(array $connections = [])
 {
     $this->client->run($connections);
 }