WARNING: Do not use this, it's only for internal use.
Changes to this function won't be recorded on the version.
public handleDataPacket ( |
||
$packet |
public function processBatch(BatchPacket $packet, Player $p) { $str = zlib_decode($packet->payload, 1024 * 1024 * 64); //Max 64MB $len = strlen($str); $offset = 0; try { while ($offset < $len) { $pkLen = Binary::readInt(substr($str, $offset, 4)); $offset += 4; $buf = substr($str, $offset, $pkLen); $offset += $pkLen; if (($pk = $this->getPacket(ord($buf[1]))) !== null) { if ($pk::NETWORK_ID === Info::BATCH_PACKET) { throw new \InvalidStateException("Invalid BatchPacket inside BatchPacket"); } $pk->setBuffer($buf, 2); $pk->decode(); $p->handleDataPacket($pk); if ($pk->getOffset() <= 0) { return; } } } } catch (\Throwable $e) { if (\pocketmine\DEBUG > 1) { $logger = $this->server->getLogger(); if ($logger instanceof MainLogger) { $logger->debug("BatchPacket " . " 0x" . bin2hex($packet->payload)); $logger->logException($e); } } } }
public function processBatch(BatchPacket $packet, Player $p) { $str = \zlib_decode($packet->payload, 1024 * 1024 * 64); //Max 64MB $len = \strlen($str); $offset = 0; try { while ($offset < $len) { $pkLen = \PHP_INT_SIZE === 8 ? \unpack("N", \substr($str, $offset, 4))[1] << 32 >> 32 : \unpack("N", \substr($str, $offset, 4))[1]; $offset += 4; $buf = \substr($str, $offset, $pkLen); $offset += $pkLen; if (($pk = $this->getPacket(\ord($buf[0]))) !== \null) { if ($pk::NETWORK_ID === Info::BATCH_PACKET) { throw new \InvalidStateException("Invalid BatchPacket inside BatchPacket"); } $pk->setBuffer($buf, 1); $pk->decode(); $p->handleDataPacket($pk); if ($pk->getOffset() <= 0) { return; } } } } catch (\Exception $e) { if (\pocketmine\DEBUG > 1) { $logger = $this->server->getLogger(); if ($logger instanceof MainLogger) { $logger->debug("BatchPacket " . " 0x" . \bin2hex($packet->payload)); $logger->logException($e); } } } }
public function handleDataPacket(DataPacket $packet) { $this->lastPacketTime = microtime(true); return parent::handleDataPacket($packet); }
public function processBatch(BatchPacket $packet, Player $p) { try { if (strlen($packet->payload) === 0) { //prevent zlib_decode errors for incorrectly-decoded packets throw new \InvalidArgumentException("BatchPacket payload is empty or packet decode error"); } $str = zlib_decode($packet->payload, 1024 * 1024 * 64); //Max 64MB $len = strlen($str); if ($len === 0) { throw new \InvalidStateException("Decoded BatchPacket payload is empty"); } $stream = new BinaryStream($str); while ($stream->offset < $len) { $buf = $stream->getString(); if (($pk = $this->getPacket(ord($buf[0]))) !== null) { if ($pk::NETWORK_ID === Info::BATCH_PACKET) { throw new \InvalidStateException("Invalid BatchPacket inside BatchPacket"); } $pk->setBuffer($buf, 1); $pk->decode(); assert($pk->feof(), "Still " . strlen(substr($pk->buffer, $pk->offset)) . " bytes unread in " . get_class($pk)); $p->handleDataPacket($pk); } } } catch (\Throwable $e) { if (\pocketmine\DEBUG > 1) { $logger = $this->server->getLogger(); $logger->debug("BatchPacket " . " 0x" . bin2hex($packet->payload)); $logger->logException($e); } } }
public function processBatch(BatchPacket $packet, Player $p) { $str = \zlib_decode($packet->payload, 1024 * 1024 * 64); //Max 64MB $len = \strlen($str); $offset = 0; try { while ($offset < $len) { if (($pk = $this->getPacket(\ord($str[$offset++]))) !== \null) { if ($pk->pid() === Info::BATCH_PACKET) { throw new \InvalidStateException("Invalid BatchPacket inside BatchPacket"); } $pk->setBuffer($str, $offset); $pk->decode(); $p->handleDataPacket($pk); $offset += $pk->getOffset(); if ($pk->getOffset() <= 0) { return; } } } } catch (\Exception $e) { if (\pocketmine\DEBUG > 1) { $logger = $this->server->getLogger(); if ($logger instanceof MainLogger) { $logger->debug("BatchPacket " . " 0x" . \bin2hex($packet->payload)); $logger->logException($e); } } } }
public function handleDataPacket(DataPacket $packet) { parent::handleDataPacket($packet); }