mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 20:28:31 +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\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{
|
||||
$packet->encode();
|
||||
$this->putString($packet->getBinaryStream()->getBuffer());
|
||||
$this->binaryStream->putString($packet->getBinaryStream()->getBuffer());
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BinaryDataException
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
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