scheduleAsyncTask() public method

Submits an asynchronous task to the Worker Pool
public scheduleAsyncTask ( AsyncTask $task ) : void
$task AsyncTask
return void
コード例 #1
0
ファイル: Server.php プロジェクト: ZenaGamingsky/PocketBox
 public function sendUsage($type = SendUsageTask::TYPE_STATUS)
 {
     $this->scheduler->scheduleAsyncTask(new SendUsageTask($this, $type, $this->uniquePlayers));
     $this->uniquePlayers = [];
 }
コード例 #2
0
ファイル: Server.php プロジェクト: ZenaGamingsky/Steadfast2
 public function sendUsage()
 {
     if ($this->lastSendUsage instanceof SendUsageTask) {
         if (!$this->lastSendUsage->isGarbage()) {
             //do not call multiple times
             return;
         }
     }
     $plist = "";
     foreach ($this->getPluginManager()->getPlugins() as $p) {
         $d = $p->getDescription();
         $plist .= str_replace([";", ":"], "", $d->getName()) . ":" . str_replace([";", ":"], "", $d->getVersion()) . ";";
     }
     $version = new VersionString();
     $this->lastSendUsage = new SendUsageTask("http://stats.pocketmine.net/usage.php", ["serverid" => 0, "port" => $this->getPort(), "os" => Utils::getOS(), "name" => $this->getName(), "memory_total" => $this->getConfigString("memory-limit"), "memory_usage" => memory_get_usage(), "php_version" => PHP_VERSION, "version" => $version->get(true), "build" => $version->getBuild(), "mc_version" => \pocketmine\MINECRAFT_VERSION, "protocol" => \pocketmine\network\protocol\Info::CURRENT_PROTOCOL, "online" => count($this->players), "max" => $this->getMaxPlayers(), "plugins" => $plist]);
     $this->scheduler->scheduleAsyncTask($this->lastSendUsage);
 }