mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-18 19:55:33 +00:00
Added class method DataPacket->canBeBatched()
This commit is contained in:
parent
56990eb28b
commit
ea0f291cb5
@ -211,7 +211,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
|
|||||||
$pk = $packet->__encapsulatedPacket;
|
$pk = $packet->__encapsulatedPacket;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$immediate and !$needACK and $packet::NETWORK_ID !== ProtocolInfo::BATCH_PACKET
|
if(!$immediate and !$needACK and $packet->canBeBatched()
|
||||||
and Network::$BATCH_THRESHOLD >= 0
|
and Network::$BATCH_THRESHOLD >= 0
|
||||||
and strlen($packet->buffer) >= Network::$BATCH_THRESHOLD){
|
and strlen($packet->buffer) >= Network::$BATCH_THRESHOLD){
|
||||||
$this->server->batchPackets([$player], [$packet], true);
|
$this->server->batchPackets([$player], [$packet], true);
|
||||||
|
@ -31,6 +31,10 @@ class BatchPacket extends DataPacket{
|
|||||||
|
|
||||||
public $payload;
|
public $payload;
|
||||||
|
|
||||||
|
public function canBeBatched() : bool{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public function decode(){
|
public function decode(){
|
||||||
$this->payload = $this->getString();
|
$this->payload = $this->getString();
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,10 @@ abstract class DataPacket extends BinaryStream{
|
|||||||
return $this::NETWORK_ID;
|
return $this::NETWORK_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function canBeBatched() : bool{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
abstract public function encode();
|
abstract public function encode();
|
||||||
|
|
||||||
abstract public function decode();
|
abstract public function decode();
|
||||||
|
@ -44,6 +44,10 @@ class LoginPacket extends DataPacket{
|
|||||||
|
|
||||||
public $clientData = [];
|
public $clientData = [];
|
||||||
|
|
||||||
|
public function canBeBatched() : bool{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public function decode(){
|
public function decode(){
|
||||||
$this->protocol = $this->getInt();
|
$this->protocol = $this->getInt();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user