mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Merge branch 'next-minor' into next-major
This commit is contained in:
@ -1378,14 +1378,16 @@ class Server{
|
||||
*
|
||||
* @param bool|null $sync Compression on the main thread (true) or workers (false). Default is automatic (null).
|
||||
*/
|
||||
public function prepareBatch(PacketBatch $stream, Compressor $compressor, ?bool $sync = null) : CompressBatchPromise{
|
||||
public function prepareBatch(PacketBatch $stream, Compressor $compressor, ?bool $sync = null, ?TimingsHandler $timings = null) : CompressBatchPromise{
|
||||
$timings ??= Timings::$playerNetworkSendCompress;
|
||||
try{
|
||||
Timings::$playerNetworkSendCompress->startTiming();
|
||||
$timings->startTiming();
|
||||
|
||||
$buffer = $stream->getBuffer();
|
||||
|
||||
if($sync === null){
|
||||
$sync = !($this->networkCompressionAsync && $compressor->willCompress($buffer));
|
||||
$threshold = $compressor->getCompressionThreshold();
|
||||
$sync = !$this->networkCompressionAsync || $threshold === null || strlen($stream->getBuffer()) < $threshold;
|
||||
}
|
||||
|
||||
$promise = new CompressBatchPromise();
|
||||
@ -1398,7 +1400,7 @@ class Server{
|
||||
|
||||
return $promise;
|
||||
}finally{
|
||||
Timings::$playerNetworkSendCompress->stopTiming();
|
||||
$timings->stopTiming();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user