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


PHP Binary::readLong方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: decode

 public function decode()
 {
     parent::decode();
     $this->pingID = Binary::readLong($this->get(8));
 }
开发者ID:TylerAndrew,项目名称:ClearSky,代码行数:5,代码来源:PONG_DataPacket.php

示例10: handlePacket

 /**
  * @return bool
  */
 public function handlePacket()
 {
     if (strlen($packet = $this->server->readThreadToMainPacket()) > 0) {
         $id = ord($packet[0]);
         $offset = 1;
         if ($id === RakLib::PACKET_ENCAPSULATED) {
             $len = ord($packet[$offset++]);
             $identifier = substr($packet, $offset, $len);
             $offset += $len;
             $flags = ord($packet[$offset++]);
             $buffer = substr($packet, $offset);
             $this->instance->handleEncapsulated($identifier, EncapsulatedPacket::fromBinary($buffer, true), $flags);
         } elseif ($id === RakLib::PACKET_RAW) {
             $len = ord($packet[$offset++]);
             $address = substr($packet, $offset, $len);
             $offset += $len;
             $port = unpack("n", substr($packet, $offset, 2))[1];
             $offset += 2;
             $payload = substr($packet, $offset);
             $this->instance->handleRaw($address, $port, $payload);
         } elseif ($id === RakLib::PACKET_SET_OPTION) {
             $len = ord($packet[$offset++]);
             $name = substr($packet, $offset, $len);
             $offset += $len;
             $value = substr($packet, $offset);
             $this->instance->handleOption($name, $value);
         } elseif ($id === RakLib::PACKET_OPEN_SESSION) {
             $len = ord($packet[$offset++]);
             $identifier = substr($packet, $offset, $len);
             $offset += $len;
             $len = ord($packet[$offset++]);
             $address = substr($packet, $offset, $len);
             $offset += $len;
             $port = unpack("n", substr($packet, $offset, 2))[1];
             $offset += 2;
             $clientID = Binary::readLong(substr($packet, $offset, 8));
             $this->instance->openSession($identifier, $address, $port, $clientID);
         } elseif ($id === RakLib::PACKET_CLOSE_SESSION) {
             $len = ord($packet[$offset++]);
             $identifier = substr($packet, $offset, $len);
             $offset += $len;
             $len = ord($packet[$offset++]);
             $reason = substr($packet, $offset, $len);
             $this->instance->closeSession($identifier, $reason);
         } elseif ($id === RakLib::PACKET_INVALID_SESSION) {
             $len = ord($packet[$offset++]);
             $identifier = substr($packet, $offset, $len);
             $this->instance->closeSession($identifier, "Invalid session");
         } elseif ($id === RakLib::PACKET_ACK_NOTIFICATION) {
             $len = ord($packet[$offset++]);
             $identifier = substr($packet, $offset, $len);
             $offset += $len;
             $identifierACK = PHP_INT_SIZE === 8 ? unpack("N", substr($packet, $offset, 4))[1] << 32 >> 32 : unpack("N", substr($packet, $offset, 4))[1];
             $this->instance->notifyACK($identifier, $identifierACK);
         }
         return true;
     }
     return false;
 }
开发者ID:orlando092,项目名称:ImagicalMine,代码行数:62,代码来源:ServerHandler.php

示例11: getLong

 protected function getLong($signed = \true)
 {
     return Binary::readLong($this->get(8), $signed);
 }
开发者ID:xpyctum,项目名称:PocketMinePlusPlus,代码行数:4,代码来源:Packet__64bit.php

示例12: handleEncapsulatedPacketRoute

 protected function handleEncapsulatedPacketRoute(EncapsulatedPacket $packet)
 {
     if ($this->sessionManager === null) {
         return;
     }
     $id = ord($packet->buffer[0]);
     if ($id < 0x80) {
         //internal data packet
         if ($this->state === self::STATE_CONNECTING_2) {
             if ($id === CLIENT_CONNECT_DataPacket::$ID) {
                 $dataPacket = new CLIENT_CONNECT_DataPacket();
                 $dataPacket->buffer = $packet->buffer;
                 $dataPacket->decode();
                 $pk = new SERVER_HANDSHAKE_DataPacket();
                 $pk->port = $this->port;
                 $pk->session = $dataPacket->session;
                 $pk->session2 = Binary::readLong("D\v©");
                 $pk->encode();
                 $sendPacket = new EncapsulatedPacket();
                 $sendPacket->reliability = 0;
                 $sendPacket->buffer = $pk->buffer;
                 $this->addToQueue($sendPacket, RakLib::PRIORITY_IMMEDIATE);
             } elseif ($id === CLIENT_HANDSHAKE_DataPacket::$ID) {
                 $dataPacket = new CLIENT_HANDSHAKE_DataPacket();
                 $dataPacket->buffer = $packet->buffer;
                 $dataPacket->decode();
                 if ($dataPacket->port === $this->sessionManager->getPort() or !$this->sessionManager->portChecking) {
                     $this->state = self::STATE_CONNECTED;
                     //FINALLY!
                     $this->sessionManager->openSession($this);
                     foreach ($this->preJoinQueue as $p) {
                         $this->sessionManager->streamEncapsulated($this, $p);
                     }
                     $this->preJoinQueue = [];
                 }
             }
         } elseif ($id === CLIENT_DISCONNECT_DataPacket::$ID) {
             $this->disconnect("client disconnect");
         } elseif ($id === PING_DataPacket::$ID) {
             $dataPacket = new PING_DataPacket();
             $dataPacket->buffer = $packet->buffer;
             $dataPacket->decode();
             $pk = new PONG_DataPacket();
             $pk->pingID = $dataPacket->pingID;
             $pk->encode();
             $sendPacket = new EncapsulatedPacket();
             $sendPacket->reliability = 0;
             $sendPacket->buffer = $pk->buffer;
             $this->addToQueue($sendPacket);
         }
         //TODO: add PING/PONG (0x00/0x03) automatic latency measure
     } elseif ($this->state === self::STATE_CONNECTED) {
         $this->sessionManager->streamEncapsulated($this, $packet);
         //TODO: split packet handling
         //TODO: stream channels
     } else {
         $this->preJoinQueue[] = $packet;
     }
 }
开发者ID:hlogeon,项目名称:PocketMineJs-MP,代码行数:59,代码来源:Session.php


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