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


PHP Binary::readLTriad方法代码示例

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


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

示例1: fromBinary

 /**
  * @param string $binary
  * @param bool   $internal
  * @param int    &$offset
  *
  * @return EncapsulatedPacket
  */
 public static function fromBinary($binary, $internal = false, &$offset = null)
 {
     $packet = new EncapsulatedPacket();
     $flags = ord($binary[0]);
     $packet->reliability = $reliability = ($flags & 0b11100000) >> 5;
     $packet->hasSplit = $hasSplit = ($flags & 0b10000) > 0;
     if ($internal) {
         $length = Binary::readInt(substr($binary, 1, 4));
         $packet->identifierACK = Binary::readInt(substr($binary, 5, 4));
         $offset = 9;
     } else {
         $length = (int) ceil(Binary::readShort(substr($binary, 1, 2)) / 8);
         $offset = 3;
         $packet->identifierACK = null;
     }
     /*
      * From http://www.jenkinssoftware.com/raknet/manual/reliabilitytypes.html
      *
      * Default: 0b010 (2) or 0b011 (3)
      *
      * 0: UNRELIABLE
      * 1: UNRELIABLE_SEQUENCED
      * 2: RELIABLE
      * 3: RELIABLE_ORDERED
      * 4: RELIABLE_SEQUENCED
      * 5: UNRELIABLE_WITH_ACK_RECEIPT
      * 6: RELIABLE_WITH_ACK_RECEIPT
      * 7: RELIABLE_ORDERED_WITH_ACK_RECEIPT
      */
     if ($reliability === 2 or $reliability === 3 or $reliability === 4 or $reliability === 6 or $reliability === 7) {
         $packet->messageIndex = Binary::readLTriad(substr($binary, $offset, 3));
         $offset += 3;
     } else {
         $packet->messageIndex = null;
     }
     if ($reliability === 1 or $reliability === 3 or $reliability === 4 or $reliability === 7) {
         $packet->orderIndex = Binary::readLTriad(substr($binary, $offset, 3));
         $offset += 3;
         $packet->orderChannel = ord($binary[$offset++]);
     } else {
         $packet->orderIndex = null;
         $packet->orderChannel = null;
     }
     if ($hasSplit) {
         $packet->splitCount = Binary::readInt(substr($binary, $offset, 4));
         $offset += 4;
         $packet->splitID = Binary::readShort(substr($binary, $offset, 2));
         $offset += 2;
         $packet->splitIndex = Binary::readInt(substr($binary, $offset, 4));
         $offset += 4;
     } else {
         $packet->splitCount = null;
         $packet->splitID = null;
         $packet->splitIndex = null;
     }
     $packet->buffer = substr($binary, $offset, $length);
     $offset += $length;
     return $packet;
 }
开发者ID:hlogeon,项目名称:PocketMineJs-MP,代码行数:66,代码来源:EncapsulatedPacket.php

示例2: fromBinary

 /**
  * @param string $binary
  * @param bool   $internal
  * @param int	&$offset
  *
  * @return EncapsulatedPacket
  */
 public static function fromBinary($binary, $internal = false, &$offset = null)
 {
     $packet = new EncapsulatedPacket();
     $flags = ord($binary[0]);
     $packet->reliability = $reliability = ($flags & 0b11100000) >> 5;
     $packet->hasSplit = $hasSplit = ($flags & 0b10000) > 0;
     if ($internal) {
         $length = Binary::readInt(substr($binary, 1, 4));
         $packet->identifierACK = Binary::readInt(substr($binary, 5, 4));
         $offset = 9;
     } else {
         $length = (int) ceil(Binary::readShort(substr($binary, 1, 2)) / 8);
         $offset = 3;
         $packet->identifierACK = null;
     }
     if ($reliability > PacketReliability::UNRELIABLE) {
         if ($reliability >= PacketReliability::RELIABLE and $reliability !== PacketReliability::UNRELIABLE_WITH_ACK_RECEIPT) {
             $packet->messageIndex = Binary::readLTriad(substr($binary, $offset, 3));
             $offset += 3;
         }
         if ($reliability <= PacketReliability::RELIABLE_SEQUENCED and $reliability !== PacketReliability::RELIABLE) {
             $packet->orderIndex = Binary::readLTriad(substr($binary, $offset, 3));
             $offset += 3;
             $packet->orderChannel = ord($binary[$offset++]);
         }
     }
     if ($hasSplit) {
         $packet->splitCount = Binary::readInt(substr($binary, $offset, 4));
         $offset += 4;
         $packet->splitID = Binary::readShort(substr($binary, $offset, 2));
         $offset += 2;
         $packet->splitIndex = Binary::readInt(substr($binary, $offset, 4));
         $offset += 4;
     }
     $packet->buffer = substr($binary, $offset, $length);
     $offset += $length;
     return $packet;
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:45,代码来源:EncapsulatedPacket.php

示例3: getLTriad

 protected function getLTriad()
 {
     return Binary::readLTriad($this->get(3));
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:4,代码来源:Packet.php


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