當前位置: 首頁>>代碼示例>>PHP>>正文


PHP raklib\Binary類代碼示例

本文整理匯總了PHP中raklib\Binary的典型用法代碼示例。如果您正苦於以下問題:PHP Binary類的具體用法?PHP Binary怎麽用?PHP Binary使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Binary類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: decode

 public function decode()
 {
     parent::decode();
     $this->clientID = Binary::readLong($this->get(8));
     $this->session = Binary::readLong($this->get(8));
     $this->unknown = $this->get(1);
 }
開發者ID:Hydreon,項目名稱:PMSoft238,代碼行數:7,代碼來源:CLIENT_CONNECT_DataPacket.php

示例2: decode

 public function decode()
 {
     parent::decode();
     $this->clientID = Binary::readLong($this->get(8));
     $this->sendPing = Binary::readLong($this->get(8));
     $this->useSecurity = \ord($this->get(1)) > 0;
 }
開發者ID:xpyctum,項目名稱:PocketMinePlusPlus,代碼行數:7,代碼來源:CLIENT_CONNECT_DataPacket__32bit.php

示例3: decode

 public function decode()
 {
     parent::decode();
     $this->pingID = Binary::readLong($this->get(8));
     $this->serverID = Binary::readLong($this->get(8));
     $this->offset += 16;
     //magic
     $this->serverName = $this->getString();
 }
開發者ID:kakichi,項目名稱:ClearSky,代碼行數:9,代碼來源:UNCONNECTED_PONG.php

示例4: decode

 public function decode()
 {
     parent::decode();
     $this->offset += 16;
     //Magic
     $this->getAddress($this->serverAddress, $this->serverPort);
     $this->mtuSize = \unpack("n", $this->get(2))[1];
     $this->clientID = Binary::readLong($this->get(8));
 }
開發者ID:xpyctum,項目名稱:PocketMinePlusPlus,代碼行數:9,代碼來源:OPEN_CONNECTION_REQUEST_2__64bit.php

示例5: decode

 public function decode()
 {
     parent::decode();
     $this->offset += 16;
     //Magic
     $this->serverID = Binary::readLong($this->get(8));
     $this->clientPort = unpack("n", $this->get(2))[1];
     $this->mtuSize = unpack("n", $this->get(2))[1];
     //server security
 }
開發者ID:Hydreon,項目名稱:PMSoft238,代碼行數:10,代碼來源:OPEN_CONNECTION_REPLY_2.php

示例6: decode

 public function decode()
 {
     parent::decode();
     $this->offset += 16;
     //Magic
     $this->serverID = Binary::readLong($this->get(8));
     \ord($this->get(1));
     //security
     $this->mtuSize = \unpack("n", $this->get(2))[1];
 }
開發者ID:TylerAndrew,項目名稱:Steadfast2,代碼行數:10,代碼來源:OPEN_CONNECTION_REPLY_1.php

示例7: encode

 public function encode()
 {
     parent::encode();
     $this->putAddress($this->address, $this->port, 4);
     $this->buffer .= pack("n", 0);
     for ($i = 0; $i < 10; ++$i) {
         $this->putAddress($this->systemAddresses[$i][0], $this->systemAddresses[$i][1], $this->systemAddresses[$i][2]);
     }
     $this->buffer .= Binary::writeLong($this->sendPing);
     $this->buffer .= Binary::writeLong($this->sendPong);
 }
開發者ID:TylerAndrew,項目名稱:ClearSky,代碼行數:11,代碼來源:SERVER_HANDSHAKE_DataPacket.php

示例8: decode

 public function decode()
 {
     parent::decode();
     $this->getAddress($this->address, $this->port);
     for ($i = 0; $i < 10; ++$i) {
         $this->getAddress($addr, $port, $version);
         $this->systemAddresses[$i] = [$addr, $port, $version];
     }
     $this->sendPing = Binary::readLong($this->get(8));
     $this->sendPong = Binary::readLong($this->get(8));
 }
開發者ID:TylerAndrew,項目名稱:Steadfast2,代碼行數:11,代碼來源:CLIENT_HANDSHAKE_DataPacket.php

示例9: decode

 public function decode()
 {
     parent::decode();
     $this->cookie = $this->get(4);
     $this->security = $this->get(1);
     $this->port = unpack("n", $this->get(2))[1];
     $this->dataArray0 = $this->get(ord($this->get(1)));
     $this->dataArray = $this->getDataArray(9);
     $this->timestamp = $this->get(2);
     $this->session2 = Binary::readLong($this->get(8));
     $this->session = Binary::readLong($this->get(8));
 }
開發者ID:Hydreon,項目名稱:PMSoft238,代碼行數:12,代碼來源:CLIENT_HANDSHAKE_DataPacket.php

示例10: encode

 public function encode()
 {
     parent::encode();
     $this->buffer .= "?Wþ";
     //cookie
     $this->buffer .= "Í";
     //security flags
     $this->buffer .= pack("n", $this->port);
     $this->putDataArray(["õÿÿõ", "ÿÿÿÿ", "ÿÿÿÿ", "ÿÿÿÿ", "ÿÿÿÿ", "ÿÿÿÿ", "ÿÿÿÿ", "ÿÿÿÿ", "ÿÿÿÿ", "ÿÿÿÿ"]);
     $this->buffer .= "";
     $this->buffer .= Binary::writeLong($this->session);
     $this->buffer .= Binary::writeLong($this->session2);
 }
開發者ID:Hydreon,項目名稱:PMSoft238,代碼行數:13,代碼來源:SERVER_HANDSHAKE_DataPacket.php

示例11: encode

 public function encode()
 {
     parent::encode();
     $payload = "";
     sort($this->packets, SORT_NUMERIC);
     $count = count($this->packets);
     $records = 0;
     if ($count > 0) {
         $pointer = 1;
         $start = $this->packets[0];
         $last = $this->packets[0];
         while ($pointer < $count) {
             $current = $this->packets[$pointer++];
             $diff = $current - $last;
             if ($diff === 1) {
                 $last = $current;
             } elseif ($diff > 1) {
                 //Forget about duplicated packets (bad queues?)
                 if ($start === $last) {
                     $payload .= "";
                     $payload .= Binary::writeLTriad($start);
                     $start = $last = $current;
                 } else {
                     $payload .= "";
                     $payload .= Binary::writeLTriad($start);
                     $payload .= Binary::writeLTriad($last);
                     $start = $last = $current;
                 }
                 ++$records;
             }
         }
         if ($start === $last) {
             $payload .= "";
             $payload .= Binary::writeLTriad($start);
         } else {
             $payload .= "";
             $payload .= Binary::writeLTriad($start);
             $payload .= Binary::writeLTriad($last);
         }
         ++$records;
     }
     $this->putShort($records);
     $this->buffer .= $payload;
 }
開發者ID:iTXTech,項目名稱:Genisys,代碼行數:44,代碼來源:AcknowledgePacket.php

示例12: getChunkCacheFromData

 /**
  * @param $chunkX
  * @param $chunkZ
  * @param $payload
  *
  * @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::writeInt(strlen($pk->getBuffer())) . $pk->getBuffer(), ZLIB_ENCODING_DEFLATE, Server::getInstance()->networkCompressionLevel);
     $batch->encode();
     $batch->isEncoded = true;
     return $batch;
 }
開發者ID:NewDelion,項目名稱:PocketMine-0.13.x,代碼行數:21,代碼來源:Player.php

示例13: toBinary

 /**
  * @param bool $internal
  *
  * @return string
  */
 public function toBinary($internal = false)
 {
     $binary = chr($this->reliability << 5 | ($this->hasSplit ? 0b10000 : 0));
     if ($internal) {
         $binary .= Binary::writeInt(strlen($this->buffer));
         $binary .= Binary::writeInt($this->identifierACK);
     } else {
         $binary .= Binary::writeShort(strlen($this->buffer) << 3);
     }
     if ($this->reliability === 2 or $this->reliability === 3 or $this->reliability === 4 or $this->reliability === 6 or $this->reliability === 7) {
         $binary .= Binary::writeLTriad($this->messageIndex);
     }
     if ($this->reliability === 1 or $this->reliability === 3 or $this->reliability === 4 or $this->reliability === 7) {
         $binary .= Binary::writeLTriad($this->orderIndex) . chr($this->orderChannel);
     }
     if ($this->hasSplit) {
         $binary .= Binary::writeInt($this->splitCount) . Binary::writeShort($this->splitID) . Binary::writeInt($this->splitIndex);
     }
     return $binary . $this->buffer;
 }
開發者ID:hlogeon,項目名稱:PocketMineJs-MP,代碼行數:25,代碼來源:EncapsulatedPacket.php

示例14: streamOpen

 protected function streamOpen(Session $session)
 {
     $identifier = $session->getAddress() . ":" . $session->getPort();
     $buffer = \chr(RakLib::PACKET_OPEN_SESSION) . \chr(\strlen($identifier)) . $identifier . \chr(\strlen($session->getAddress())) . $session->getAddress() . \pack("n", $session->getPort()) . Binary::writeLong($session->getID());
     $this->server->pushThreadToMainPacket($buffer);
 }
開發者ID:kakichi,項目名稱:ClearSky,代碼行數:6,代碼來源:SessionManager.php

示例15: saveChunkToDisk

 public function saveChunkToDisk($x, $z, $payload, $ordering = FullChunkDataPacket::ORDER_COLUMNS)
 {
     /** @var Player $player */
     if (file_exists("chunk_cache/" . $this->getName() . "/" . $x . "_" . $z . ".dat")) {
         $this->loadChunkFromDisk($x, $z);
         return true;
     }
     $pk = new FullChunkDataPacket();
     $pk->chunkX = $x;
     $pk->chunkZ = $z;
     $pk->order = $ordering;
     $pk->data = $payload;
     $pk->encode();
     $data = zlib_encode(Binary::writeInt(strlen($pk->buffer)) . $pk->buffer, ZLIB_ENCODING_DEFLATE, 6);
     $this->chunkCache[$x . ":" . $z] = $data;
     if (!$this->server->getKatana()->getProperty("cache.save-to-disk", true)) {
         return true;
     }
     file_put_contents("chunk_cache/" . $this->getName() . "/" . $x . "_" . $z . ".dat", $data);
     return true;
 }
開發者ID:TexusDark,項目名稱:Katana,代碼行數:21,代碼來源:Level.php


注:本文中的raklib\Binary類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。