rename PacketStream to PacketBatch

This commit is contained in:
Dylan K. Taylor 2019-05-06 19:58:02 +01:00
parent ce61c6e0fd
commit 427e334426
5 changed files with 13 additions and 13 deletions

View File

@ -67,7 +67,7 @@ use pocketmine\network\mcpe\CompressBatchTask;
use pocketmine\network\mcpe\NetworkCipher; use pocketmine\network\mcpe\NetworkCipher;
use pocketmine\network\mcpe\NetworkCompression; use pocketmine\network\mcpe\NetworkCompression;
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
use pocketmine\network\mcpe\PacketStream; use pocketmine\network\mcpe\PacketBatch;
use pocketmine\network\mcpe\protocol\ClientboundPacket; use pocketmine\network\mcpe\protocol\ClientboundPacket;
use pocketmine\network\mcpe\protocol\PlayerListPacket; use pocketmine\network\mcpe\protocol\PlayerListPacket;
use pocketmine\network\mcpe\protocol\ProtocolInfo; use pocketmine\network\mcpe\protocol\ProtocolInfo;
@ -1492,7 +1492,7 @@ class Server{
} }
$recipients = $ev->getTargets(); $recipients = $ev->getTargets();
$stream = PacketStream::fromPackets(...$ev->getPackets()); $stream = PacketBatch::fromPackets(...$ev->getPackets());
if(NetworkCompression::$THRESHOLD < 0 or strlen($stream->getBuffer()) < NetworkCompression::$THRESHOLD){ if(NetworkCompression::$THRESHOLD < 0 or strlen($stream->getBuffer()) < NetworkCompression::$THRESHOLD){
foreach($recipients as $target){ foreach($recipients as $target){
@ -1513,12 +1513,12 @@ class Server{
/** /**
* Broadcasts a list of packets in a batch to a list of players * Broadcasts a list of packets in a batch to a list of players
* *
* @param PacketStream $stream * @param PacketBatch $stream
* @param bool $forceSync * @param bool $forceSync
* *
* @return CompressBatchPromise * @return CompressBatchPromise
*/ */
public function prepareBatch(PacketStream $stream, bool $forceSync = false) : CompressBatchPromise{ public function prepareBatch(PacketBatch $stream, bool $forceSync = false) : CompressBatchPromise{
try{ try{
Timings::$playerNetworkSendCompressTimer->startTiming(); Timings::$playerNetworkSendCompressTimer->startTiming();

View File

@ -26,7 +26,7 @@ namespace pocketmine\inventory;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\network\mcpe\CompressBatchPromise; use pocketmine\network\mcpe\CompressBatchPromise;
use pocketmine\network\mcpe\NetworkCompression; use pocketmine\network\mcpe\NetworkCompression;
use pocketmine\network\mcpe\PacketStream; use pocketmine\network\mcpe\PacketBatch;
use pocketmine\network\mcpe\protocol\CraftingDataPacket; use pocketmine\network\mcpe\protocol\CraftingDataPacket;
use pocketmine\timings\Timings; use pocketmine\timings\Timings;
use function array_map; use function array_map;
@ -116,7 +116,7 @@ class CraftingManager{
} }
$this->craftingDataCache = new CompressBatchPromise(); $this->craftingDataCache = new CompressBatchPromise();
$this->craftingDataCache->resolve(NetworkCompression::compress(PacketStream::fromPackets($pk)->getBuffer())); $this->craftingDataCache->resolve(NetworkCompression::compress(PacketBatch::fromPackets($pk)->getBuffer()));
Timings::$craftingDataCacheRebuildTimer->stopTiming(); Timings::$craftingDataCacheRebuildTimer->stopTiming();
} }

View File

@ -57,7 +57,7 @@ class ChunkRequestTask extends AsyncTask{
$pk->chunkZ = $this->chunkZ; $pk->chunkZ = $this->chunkZ;
$pk->data = $this->chunk; $pk->data = $this->chunk;
$this->setResult(NetworkCompression::compress(PacketStream::fromPackets($pk)->getBuffer(), $this->compressionLevel)); $this->setResult(NetworkCompression::compress(PacketBatch::fromPackets($pk)->getBuffer(), $this->compressionLevel));
} }
public function onError() : void{ public function onError() : void{

View File

@ -119,7 +119,7 @@ class NetworkSession{
/** @var NetworkCipher */ /** @var NetworkCipher */
private $cipher; private $cipher;
/** @var PacketStream|null */ /** @var PacketBatch|null */
private $sendBuffer; private $sendBuffer;
/** @var \SplQueue|CompressBatchPromise[] */ /** @var \SplQueue|CompressBatchPromise[] */
@ -264,7 +264,7 @@ class NetworkSession{
Timings::$playerNetworkReceiveDecompressTimer->startTiming(); Timings::$playerNetworkReceiveDecompressTimer->startTiming();
try{ try{
$stream = new PacketStream(NetworkCompression::decompress($payload)); $stream = new PacketBatch(NetworkCompression::decompress($payload));
}catch(\ErrorException $e){ }catch(\ErrorException $e){
$this->logger->debug("Failed to decompress packet: " . bin2hex($payload)); $this->logger->debug("Failed to decompress packet: " . bin2hex($payload));
//TODO: this isn't incompatible game version if we already established protocol version //TODO: this isn't incompatible game version if we already established protocol version
@ -359,7 +359,7 @@ class NetworkSession{
$timings->startTiming(); $timings->startTiming();
try{ try{
if($this->sendBuffer === null){ if($this->sendBuffer === null){
$this->sendBuffer = new PacketStream(); $this->sendBuffer = new PacketBatch();
} }
$this->sendBuffer->putPacket($packet); $this->sendBuffer->putPacket($packet);
$this->manager->scheduleUpdate($this); //schedule flush at end of tick $this->manager->scheduleUpdate($this); //schedule flush at end of tick

View File

@ -27,7 +27,7 @@ use pocketmine\network\mcpe\protocol\Packet;
use pocketmine\network\mcpe\protocol\PacketPool; use pocketmine\network\mcpe\protocol\PacketPool;
use pocketmine\utils\BinaryDataException; use pocketmine\utils\BinaryDataException;
class PacketStream extends NetworkBinaryStream{ class PacketBatch extends NetworkBinaryStream{
public function putPacket(Packet $packet) : void{ public function putPacket(Packet $packet) : void{
if(!$packet->isEncoded()){ if(!$packet->isEncoded()){
@ -49,7 +49,7 @@ class PacketStream extends NetworkBinaryStream{
* *
* @param Packet ...$packets * @param Packet ...$packets
* *
* @return PacketStream * @return PacketBatch
*/ */
public static function fromPackets(Packet ...$packets) : self{ public static function fromPackets(Packet ...$packets) : self{
$result = new self(); $result = new self();