示例#1
0
 public function testWrite()
 {
     $testData = array('a' => 'b');
     $encodedData = json_encode($testData);
     $dataLength = strlen($encodedData);
     $this->encoder->expects($this->once())->method('toCompressedFrame')->with($this->equalTo($testData), $this->equalTo(1))->willReturn($encodedData);
     $this->socket->expects($this->once())->method('write')->with($this->equalTo($encodedData))->willReturn($dataLength);
     $actual = $this->instance->write($testData);
     $this->assertEquals($dataLength, $actual);
 }
 /** {@inheritdoc} */
 public function getStreamResource()
 {
     return $this->origin->getStreamResource();
 }
示例#3
0
 /**
  * @return int
  */
 private function readLastAck()
 {
     $unpacked = unpack('N', $this->socket->read(4));
     return reset($unpacked);
 }
示例#4
0
 /**
  * 
  * @param SocketInterface $socket
  * @return int
  */
 protected function getSocketIndex($socket)
 {
     $index = 0;
     foreach ($this->sockets as $subSocket) {
         if ($subSocket->getId() == $socket->getId()) {
             break;
         }
         $index++;
     }
     return $index;
 }