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


PHP Binary::writeUnsignedVarInt方法代码示例

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


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

示例1: getChunkCacheFromData

 /**
  * @param int    $chunkX
  * @param int    $chunkZ
  * @param string $payload
  * @param int    $ordering
  *
  * @return DataPacket
  */
 public static function getChunkCacheFromData($chunkX, $chunkZ, $payload, $ordering = FullChunkDataPacket::ORDER_COLUMNS)
 {
     $pk = new FullChunkDataPacket();
     $pk->chunkX = $chunkX;
     $pk->chunkZ = $chunkZ;
     $pk->order = $ordering;
     $pk->data = $payload;
     $pk->encode();
     $batch = new BatchPacket();
     $batch->payload = zlib_encode(Binary::writeUnsignedVarInt(strlen($pk->getBuffer())) . $pk->getBuffer(), ZLIB_ENCODING_DEFLATE, Server::getInstance()->networkCompressionLevel);
     $batch->encode();
     $batch->isEncoded = true;
     return $batch;
 }
开发者ID:xxFlare,项目名称:PocketMine-MP,代码行数:22,代码来源:Player.php

示例2: putUnsignedVarInt

 /**
  * Writes an unsigned varint32 to the stream.
  */
 public function putUnsignedVarInt($v)
 {
     $this->put(Binary::writeUnsignedVarInt($v));
 }
开发者ID:robske110,项目名称:ClearSky,代码行数:7,代码来源:BinaryStream.php

示例3: batchPackets

 /**
  * Broadcasts a list of packets in a batch to a list of players
  *
  * @param Player[]            $players
  * @param DataPacket[]|string $packets
  * @param bool                $forceSync
  */
 public function batchPackets(array $players, array $packets, $forceSync = false)
 {
     Timings::$playerNetworkTimer->startTiming();
     $str = "";
     foreach ($packets as $p) {
         if ($p instanceof DataPacket) {
             if (!$p->isEncoded) {
                 $p->encode();
             }
             $str .= Binary::writeUnsignedVarInt(strlen($p->buffer)) . $p->buffer;
         } else {
             $str .= Binary::writeUnsignedVarInt(strlen($p)) . $p;
         }
     }
     $targets = [];
     foreach ($players as $p) {
         if ($p->isConnected()) {
             $targets[] = $this->identifiers[spl_object_hash($p)];
         }
     }
     if (!$forceSync and $this->networkCompressionAsync) {
         $task = new CompressBatchedTask($str, $targets, $this->networkCompressionLevel);
         $this->getScheduler()->scheduleAsyncTask($task);
     } else {
         $this->broadcastPacketsCallback(zlib_encode($str, ZLIB_ENCODING_DEFLATE, $this->networkCompressionLevel), $targets);
     }
     Timings::$playerNetworkTimer->stopTiming();
 }
开发者ID:robske110,项目名称:ClearSky,代码行数:35,代码来源:Server.php


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