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
コード例 #1
0
ファイル: IrcClient.php プロジェクト: jlkaufman/blackhole-bot
 /**
  * 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);
     });
 }
コード例 #2
0
 /**
  * Tests that the client emits a periodic event per connection.
  */
 public function testTickCallback()
 {
     $connection = $this->getMockConnectionForAddConnection();
     $logger = $this->getMockLogger();
     $loop = $this->getMockLoop();
     $writeStream = $this->getMockWriteStream();
     $timer = $this->getMockTimer();
     Phake::when($this->client)->getWriteStream($connection)->thenReturn($writeStream);
     Phake::when($loop)->addPeriodicTimer(0.2, $this->isType('callable'))->thenReturn($timer);
     $this->client->setLoop($loop);
     $this->client->setLogger($logger);
     $this->client->setResolver($this->getMockResolver());
     $this->client->addConnection($connection);
     Phake::verify($loop)->addPeriodicTimer(0.2, Phake::capture($callback));
     $callback();
     Phake::verify($this->client)->emit('irc.tick', Phake::capture($params));
     $this->assertInternalType('array', $params);
     $this->assertCount(3, $params);
     $this->assertSame($writeStream, $params[0]);
     $this->assertSame($connection, $params[1]);
     $this->assertSame($logger, $params[2]);
 }
コード例 #3
0
ファイル: ConnectionManager.php プロジェクト: stil/phoebe
 /**
  * @param ConnectionInterface $connection
  * @return void
  */
 public function addConnection(ConnectionInterface $connection)
 {
     $this->client->addConnection($connection);
 }