/**
  * @return SteamPacket
  */
 public function getReply()
 {
     $bytesRead = $this->receivePacket(1400);
     // Check wether it is a split packet
     if ($this->buffer->getLong() == -2) {
         do {
             $requestId = $this->buffer->getLong();
             $packetCountAndNumber = $this->buffer->getByte();
             $packetCount = $packetCountAndNumber & 0xf;
             $packetNumber = ($packetCountAndNumber >> 4) + 1;
             // Caching of split packet Data
             $splitPackets[$packetNumber - 1] = $this->buffer->get();
             trigger_error("Received packet {$packetNumber} of {$packetCount} for request #{$requestId}");
             // Receiving the next packet
             if (sizeof($splitPackets) < $packetCount) {
                 try {
                     $bytesRead = $this->receivePacket();
                 } catch (TimeoutException $e) {
                     $bytesRead = 0;
                 }
             } else {
                 $bytesRead = 0;
             }
         } while ($bytesRead > 0 && $this->buffer->getLong() == -2);
         $packet = SteamPacketFactory::reassemblePacket($splitPackets);
     } else {
         $packet = SteamPacketFactory::getPacketFromData($this->buffer->get());
     }
     trigger_error("Received packet of type \"" . get_class($packet) . "\"");
     return $packet;
 }
 /**
  * @throws PacketFormatException
  */
 public function getReply()
 {
     $this->receivePacket(1500);
     if ($this->buffer->getLong() != -1) {
         throw new PacketFormatException("Master query response has wrong packet header.");
     }
     return SteamPacketFactory::getPacketFromData($this->buffer->get());
 }
 /**
  * Reads a single packet from the socket
  *
  * @return SteamPacket The packet replied from the server
  * @throws PacketFormatException if the packet has the wrong format
  */
 public function getReply()
 {
     $this->receivePacket(1500);
     if ($this->buffer->getLong() != -1) {
         throw new PacketFormatException("Master query response has wrong packet header.");
     }
     $packet = SteamPacketFactory::getPacketFromData($this->buffer->get());
     trigger_error("Received reply of type \"" . get_class($packet) . "\"");
     return $packet;
 }
示例#4
0
 /**
  * @return byte[]
  */
 public function getReply()
 {
     $bytesRead = $this->receivePacket(1400);
     $isCompressed = false;
     // Check wether it is a split packet
     if ($this->buffer->getLong() == -2) {
         do {
             $requestId = $this->buffer->getLong();
             $isCompressed = ($requestId & 2147483648.0) != 0;
             $packetCount = $this->buffer->getByte();
             $packetNumber = $this->buffer->getByte() + 1;
             if ($isCompressed) {
                 $splitSize = $this->buffer->getLong();
                 $packetChecksum = $this->buffer->getLong();
             } else {
                 $splitSize = $this->buffer->getShort();
             }
             // Caching of split packet Data
             $splitPackets[$packetNumber] = $this->buffer->get();
             trigger_error("Received packet {$packetNumber} of {$packetCount} for request #{$requestId}");
             // Receiving the next packet
             if (sizeof($splitPackets) < $packetCount) {
                 try {
                     $bytesRead = $this->receivePacket();
                 } catch (TimeoutException $e) {
                     $bytesRead = 0;
                 }
             } else {
                 $bytesRead = 0;
             }
         } while ($bytesRead > 0 && $this->buffer->getLong() == -2);
         if ($isCompressed) {
             $packet = SteamPacketFactory::reassemblePacket($splitPackets, true, $packetChecksum);
         } else {
             $packet = SteamPacketFactory::reassemblePacket($splitPackets);
         }
     } else {
         $packet = SteamPacketFactory::getPacketFromData($this->buffer->get());
     }
     if ($isCompressed) {
         trigger_error("Received compressed reply of type \"" . get_class($packet) . "\"");
     } else {
         trigger_error("Received reply of type \"" . get_class($packet) . "\"");
     }
     return $packet;
 }