Added class method DataPacket->canBeBatched()

This commit is contained in:
Dylan K. Taylor 2017-02-27 11:09:49 +00:00
parent 56990eb28b
commit ea0f291cb5
4 changed files with 13 additions and 1 deletions

View File

@ -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);

View File

@ -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();
} }

View File

@ -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();

View File

@ -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();