當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。