BatchPacket, compress any packet depending on the size, really fast threaded chunk sending

This commit is contained in:
Shoghi Cervantes
2015-03-25 23:50:55 +01:00
parent 7d1313c63d
commit 962c28aaca
16 changed files with 658 additions and 233 deletions

View File

@ -31,6 +31,7 @@ use pocketmine\Server;
abstract class AsyncTask extends \Collectable{
private $result = null;
private $serialized = false;
/** @var int */
private $taskId = null;
@ -55,7 +56,7 @@ abstract class AsyncTask extends \Collectable{
* @return mixed
*/
public function getResult(){
return unserialize($this->result);
return $this->serialized ? unserialize($this->result) : $this->result;
}
/**
@ -67,9 +68,11 @@ abstract class AsyncTask extends \Collectable{
/**
* @param mixed $result
* @param bool $serialize
*/
public function setResult($result){
$this->result = serialize($result);
public function setResult($result, $serialize = true){
$this->result = $serialize ? serialize($result) : $result;
$this->serialized = $serialize;
}
public function setTaskId($taskId){