Example #1
0
 /**
  * @covers PhiKettle\Kettle::__construct
  * @covers PhiKettle\Kettle::getStream
  * @covers PhiKettle\Kettle::getState
  */
 public function testConstructor()
 {
     $connection = new Connection($this->host, $this->port, new DummyLoop());
     $kettle = new Kettle($connection);
     $this->assertEquals(new KettleState(), $kettle->getState());
     $this->assertEquals($connection->getStream(), $kettle->getStream());
 }
Example #2
0
 /**
  * Check if the current node belongs to a specific server.
  *
  * @param   \Hoa\Socket\Connection  $server    Server.
  * @return  bool
  */
 public function is(Connection $server)
 {
     return $this->getStream() === $server->getStream();
 }
Example #3
0
 /**
  * Create a kettle object for passed connection object
  *
  * @param Connection $connection
  */
 public function __construct(Connection $connection)
 {
     $this->state = new KettleState();
     $this->stream = $connection->getStream();
 }
Example #4
0
 /**
  * Consider another server when selecting connection.
  *
  * @param   \Hoa\Socket\Connection  $other    Other server.
  * @return  \Hoa\Socket\Server
  */
 public function consider(Connection $other)
 {
     if ($other instanceof Client) {
         if (true === $other->isDisconnected()) {
             $other->connect();
         }
         $this->_stack[] = $other->getStream();
         return $this;
     }
     if (true === $other->isDisconnected()) {
         $other->connectAndWait();
     }
     $i = count($this->_masters);
     $this->_masters[$i] = $other->_master;
     $this->_servers[$i] = $other;
     $this->_stack[] = $this->_masters[$i];
     return $this;
 }
Example #5
0
 public function delete($path)
 {
     return @ftp_delete($this->connection->getStream(), $path);
 }