当前位置: 首页>>代码示例>>PHP>>正文


PHP Player::handleDataPacket方法代码示例

本文整理汇总了PHP中pocketmine\Player::handleDataPacket方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::handleDataPacket方法的具体用法?PHP Player::handleDataPacket怎么用?PHP Player::handleDataPacket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pocketmine\Player的用法示例。


在下文中一共展示了Player::handleDataPacket方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: processBatch

 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);
             }
         }
     }
 }
开发者ID:xpyctum,项目名称:Genisys,代码行数:34,代码来源:Network.php

示例2: processBatch

 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);
             }
         }
     }
 }
开发者ID:kazuemon,项目名称:NIGHTMARE,代码行数:34,代码来源:Network.php

示例3: handleDataPacket

 public function handleDataPacket(DataPacket $packet)
 {
     $this->lastPacketTime = microtime(true);
     return parent::handleDataPacket($packet);
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:5,代码来源:Player.php

示例4: processBatch

 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);
         }
     }
 }
开发者ID:robske110,项目名称:ClearSky,代码行数:34,代码来源:Network.php

示例5: processBatch

 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);
             }
         }
     }
 }
开发者ID:Edwardthedog2,项目名称:Steadfast2,代码行数:31,代码来源:Network.php

示例6: handleDataPacket

 public function handleDataPacket(DataPacket $packet)
 {
     parent::handleDataPacket($packet);
 }
开发者ID:organization,项目名称:DummyPlayer,代码行数:4,代码来源:DummyReceiver.php


注:本文中的pocketmine\Player::handleDataPacket方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。