mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-08 04:38:35 +00:00
PacketBatch no longer extends NetworkBinaryStream
this removes a whole bunch of crap from its API that shouldn't have been exposed. In the future we should look at splitting this into reader/writer halves, but for now this is a step in the right direction.
This commit is contained in:
parent
e96b082a54
commit
486ce140d8
@ -27,18 +27,25 @@ 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 PacketBatch extends NetworkBinaryStream{
|
class PacketBatch{
|
||||||
|
|
||||||
|
/** @var NetworkBinaryStream */
|
||||||
|
private $binaryStream;
|
||||||
|
|
||||||
|
public function __construct(?string $buffer = null){
|
||||||
|
$this->binaryStream = new NetworkBinaryStream($buffer ?? "");
|
||||||
|
}
|
||||||
|
|
||||||
public function putPacket(Packet $packet) : void{
|
public function putPacket(Packet $packet) : void{
|
||||||
$packet->encode();
|
$packet->encode();
|
||||||
$this->putString($packet->getBinaryStream()->getBuffer());
|
$this->binaryStream->putString($packet->getBinaryStream()->getBuffer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws BinaryDataException
|
* @throws BinaryDataException
|
||||||
*/
|
*/
|
||||||
public function getPacket(PacketPool $packetPool) : Packet{
|
public function getPacket(PacketPool $packetPool) : Packet{
|
||||||
return $packetPool->getPacket($this->getString());
|
return $packetPool->getPacket($this->binaryStream->getString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,4 +62,12 @@ class PacketBatch extends NetworkBinaryStream{
|
|||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getBuffer() : string{
|
||||||
|
return $this->binaryStream->getBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function feof() : bool{
|
||||||
|
return $this->binaryStream->feof();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user