mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-05 17:36:12 +00:00
DataPacket: inject buffer via parameter instead of class field (packet & stream separation, step 2)
this is not complete yet, but the final change (having the binarystream actually come from outside) is a little more disruptive, and some extra changes need to be made. This will grant some sanity in the meantime without breaking too much stuff.
This commit is contained in:
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class PhotoTransferPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::PHOTO_TRANSFER_PACKET;
|
||||
@ -37,16 +38,16 @@ class PhotoTransferPacket extends DataPacket implements ClientboundPacket{
|
||||
/** @var string */
|
||||
public $bookId; //photos are stored in a sibling directory to the games folder (screenshots/(some UUID)/bookID/example.png)
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->photoName = $this->buf->getString();
|
||||
$this->photoData = $this->buf->getString();
|
||||
$this->bookId = $this->buf->getString();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->photoName = $in->getString();
|
||||
$this->photoData = $in->getString();
|
||||
$this->bookId = $in->getString();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putString($this->photoName);
|
||||
$this->buf->putString($this->photoData);
|
||||
$this->buf->putString($this->bookId);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putString($this->photoName);
|
||||
$out->putString($this->photoData);
|
||||
$out->putString($this->bookId);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
Reference in New Issue
Block a user