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


PHP Binary::writeLTriad方法代码示例

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


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

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

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

示例3: toBinary

 /**
  * @param bool $internal
  *
  * @return string
  */
 public function toBinary($internal = false)
 {
     return chr($this->reliability << 5 | ($this->hasSplit ? 0b10000 : 0)) . ($internal ? Binary::writeInt(strlen($this->buffer)) . Binary::writeInt($this->identifierACK) : Binary::writeShort(strlen($this->buffer) << 3)) . ($this->reliability > 0 ? (($this->reliability >= 2 and $this->reliability !== 5) ? Binary::writeLTriad($this->messageIndex) : "") . (($this->reliability <= 4 and $this->reliability !== 2) ? Binary::writeLTriad($this->orderIndex) . chr($this->orderChannel) : "") : "") . ($this->hasSplit ? Binary::writeInt($this->splitCount) . Binary::writeShort($this->splitID) . Binary::writeInt($this->splitIndex) : "") . $this->buffer;
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:9,代码来源:EncapsulatedPacket.php

示例4: putLTriad

 protected function putLTriad($v)
 {
     $this->buffer .= Binary::writeLTriad($v);
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:4,代码来源:Packet.php

示例5: toBinary

 /**
  * @param bool $internal
  *
  * @return string
  */
 public function toBinary($internal = false)
 {
     return chr($this->reliability << 5 | ($this->hasSplit ? 0b10000 : 0)) . ($internal ? Binary::writeInt(strlen($this->buffer)) . Binary::writeInt($this->identifierACK) : Binary::writeShort(strlen($this->buffer) << 3)) . ($this->reliability > PacketReliability::UNRELIABLE ? (($this->reliability >= PacketReliability::RELIABLE and $this->reliability !== PacketReliability::UNRELIABLE_WITH_ACK_RECEIPT) ? Binary::writeLTriad($this->messageIndex) : "") . (($this->reliability <= PacketReliability::RELIABLE_SEQUENCED and $this->reliability !== PacketReliability::RELIABLE) ? Binary::writeLTriad($this->orderIndex) . chr($this->orderChannel) : "") : "") . ($this->hasSplit ? Binary::writeInt($this->splitCount) . Binary::writeShort($this->splitID) . Binary::writeInt($this->splitIndex) : "") . $this->buffer;
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:9,代码来源:EncapsulatedPacket.php


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