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


PHP DataPacket::getChannel方法代码示例

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


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

示例1: broadcastPacket

 /**
  * Broadcasts a Minecraft packet to a list of players
  *
  * @param Player[]   $players
  * @param DataPacket $packet
  */
 public static function broadcastPacket(array $players, DataPacket $packet)
 {
     $packet->encode();
     $packet->isEncoded = true;
     if (Network::$BATCH_THRESHOLD >= 0 and strlen($packet->buffer) >= Network::$BATCH_THRESHOLD) {
         Server::getInstance()->batchPackets($players, [$packet->buffer], false, $packet->getChannel());
         return;
     }
     foreach ($players as $player) {
         $player->dataPacket($packet);
     }
     if (isset($packet->__encapsulatedPacket)) {
         unset($packet->__encapsulatedPacket);
     }
 }
开发者ID:ZenaGamingsky,项目名称:PocketBox,代码行数:21,代码来源:Server.php

示例2: putPacket

 public function putPacket(Player $player, DataPacket $packet, $needACK = false, $immediate = false)
 {
     if (isset($this->identifiers[$h = spl_object_hash($player)])) {
         $identifier = $this->identifiers[$h];
         $pk = null;
         if (!$packet->isEncoded) {
             $packet->encode();
         } elseif (!$needACK) {
             if (!isset($packet->__encapsulatedPacket)) {
                 $packet->__encapsulatedPacket = new CachedEncapsulatedPacket();
                 $packet->__encapsulatedPacket->identifierACK = null;
                 //@todo backwart compatible - on 0.13 was
                 //$packet->__encapsulatedPacket->buffer = $packet->buffer;
                 $packet->__encapsulatedPacket->buffer = chr(0x8e) . $packet->buffer;
                 if ($packet->getChannel() !== 0) {
                     $packet->__encapsulatedPacket->reliability = 3;
                     $packet->__encapsulatedPacket->orderChannel = $packet->getChannel();
                     $packet->__encapsulatedPacket->orderIndex = 0;
                 } else {
                     $packet->__encapsulatedPacket->reliability = 2;
                 }
             }
             $pk = $packet->__encapsulatedPacket;
         }
         if (!$immediate and !$needACK and $packet::NETWORK_ID !== ProtocolInfo::BATCH_PACKET and Network::$BATCH_THRESHOLD >= 0 and strlen($packet->buffer) >= Network::$BATCH_THRESHOLD) {
             //@todo backwart compatible - on 0.13 was
             //$this->server->batchPackets([$player], [$packet], true, $packet->getChannel());
             $this->server->batchPackets([$player], [$packet], true);
             return null;
         }
         if ($pk === null) {
             $pk = new EncapsulatedPacket();
             //@todo backwart compatible - on 0.13 was
             //$pk->buffer = $packet->buffer;
             $pk->buffer = chr(0x8e) . $packet->buffer;
             if ($packet->getChannel() !== 0) {
                 $packet->reliability = 3;
                 $packet->orderChannel = $packet->getChannel();
                 $packet->orderIndex = 0;
             } else {
                 $packet->reliability = 2;
             }
             if ($needACK === true) {
                 $pk->identifierACK = $this->identifiersACK[$identifier]++;
             }
         }
         $this->interface->sendEncapsulated($identifier, $pk, ($needACK === true ? RakLib::FLAG_NEED_ACK : 0) | ($immediate === true ? RakLib::PRIORITY_IMMEDIATE : RakLib::PRIORITY_NORMAL));
         return $pk->identifierACK;
     }
     return null;
 }
开发者ID:Cecil107,项目名称:PocketMine-0.13.0,代码行数:51,代码来源:RakLibInterface.php

示例3: putPacket

 public function putPacket(Player $player, DataPacket $packet, $needACK = \false, $immediate = \false)
 {
     if (isset($this->identifiers[$player])) {
         $identifier = $this->identifiers[$player];
         $pk = \null;
         if (!$packet->isEncoded) {
             $packet->encode();
         } elseif (!$needACK) {
             if (!isset($packet->__encapsulatedPacket)) {
                 $packet->__encapsulatedPacket = new CachedEncapsulatedPacket();
                 $packet->__encapsulatedPacket->identifierACK = \null;
                 $packet->__encapsulatedPacket->buffer = $packet->buffer;
                 if ($packet->getChannel() !== 0) {
                     $packet->__encapsulatedPacket->reliability = 3;
                     $packet->__encapsulatedPacket->orderChannel = $packet->getChannel();
                     $packet->__encapsulatedPacket->orderIndex = 0;
                 } else {
                     $packet->__encapsulatedPacket->reliability = 2;
                 }
             }
             $pk = $packet->__encapsulatedPacket;
         }
         if (!$immediate and !$needACK and $packet->pid() !== ProtocolInfo::BATCH_PACKET and Network::$BATCH_THRESHOLD >= 0 and \strlen($packet->buffer) >= Network::$BATCH_THRESHOLD) {
             $this->server->batchPackets([$player], [$packet], \true, $packet->getChannel());
             return \null;
         }
         if ($pk === \null) {
             $pk = new EncapsulatedPacket();
             $pk->buffer = $packet->buffer;
             if ($packet->getChannel() !== 0) {
                 $packet->reliability = 3;
                 $packet->orderChannel = $packet->getChannel();
                 $packet->orderIndex = 0;
             } else {
                 $packet->reliability = 2;
             }
             if ($needACK === \true) {
                 $pk->identifierACK = $this->identifiersACK[$identifier]++;
             }
         }
         $this->interface->sendEncapsulated($identifier, $pk, ($needACK === \true ? RakLib::FLAG_NEED_ACK : 0) | ($immediate === \true ? RakLib::PRIORITY_IMMEDIATE : RakLib::PRIORITY_NORMAL));
         return $pk->identifierACK;
     }
     return \null;
 }
开发者ID:Edwardthedog2,项目名称:Steadfast2,代码行数:45,代码来源:RakLibInterface.php

示例4: batchDataPacket

 /**
  * Batch a Data packet into the channel list to send at the end of the tick
  *
  * @param DataPacket $packet
  *
  * @return bool
  */
 public function batchDataPacket(DataPacket $packet)
 {
     if ($this->connected === false) {
         return false;
     }
     $this->server->getPluginManager()->callEvent($ev = new DataPacketSendEvent($this, $packet));
     if ($ev->isCancelled()) {
         return false;
     }
     if (!isset($this->batchedPackets[$packet->getChannel()])) {
         $this->batchedPackets[$packet->getChannel()] = [];
     }
     $this->batchedPackets[$packet->getChannel()][] = clone $packet;
     return true;
 }
开发者ID:TylerGames,项目名称:PocketMine-MP,代码行数:22,代码来源:Player.php


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