当前位置: 首页>>代码示例>>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;未经允许,请勿转载。