예제 #1
0
 public function testReceivePacket()
 {
     $packet = new Packet();
     $mock = $this->getMockBuilder(__CLASS__)->getMock();
     $mock->expects($this->once())->method('testReceivePacket')->willReturnCallback(function ($givenPacket) use($packet) {
         $this->assertEquals($packet, $givenPacket);
     });
     $this->driver->expects($this->once())->method('read')->willReturn($packet);
     $this->connection->onPacketReceived([$mock, 'testReceivePacket']);
     $this->connection->receivePacket();
 }
예제 #2
0
 /**
  * Adds connection to list and sets connection to master mode
  *
  * @param Connection $connection
  *
  * @return $this
  */
 public function addConnection(Connection $connection)
 {
     $connection->setMasterMode();
     $connection->onPacketReceived([$this, 'receivedPacket']);
     $this->connections[$connection->getPid()] = $connection;
     return $this;
 }