Improved batch handling

This commit is contained in:
Dylan K. Taylor
2017-07-13 12:04:47 +01:00
parent 5283975f20
commit 72d1948f30
4 changed files with 43 additions and 34 deletions

View File

@ -257,6 +257,7 @@ class Server{
/** @var Player[] */
private $playerList = [];
/** @var string[] */
private $identifiers = [];
/** @var Level[] */
@ -1846,17 +1847,16 @@ class Server{
}
if(Network::$BATCH_THRESHOLD >= 0 and strlen($pk->payload) >= Network::$BATCH_THRESHOLD){
$compressionLevel = $this->networkCompressionLevel;
$pk->setCompressionLevel($this->networkCompressionLevel);
}else{
$compressionLevel = 0; //Do not compress packets under the threshold
$pk->setCompressionLevel(0); //Do not compress packets under the threshold
$forceSync = true;
}
if(!$forceSync and !$immediate and $this->networkCompressionAsync){
$task = new CompressBatchedTask($pk, $targets, $compressionLevel);
$task = new CompressBatchedTask($pk, $targets);
$this->getScheduler()->scheduleAsyncTask($task);
}else{
$pk->compress($compressionLevel);
$this->broadcastPacketsCallback($pk, $targets, $immediate);
}
}