diff --git a/src/Client/Multi.php b/src/Client/Multi.php index 3d6601a..3167eb6 100644 --- a/src/Client/Multi.php +++ b/src/Client/Multi.php @@ -294,6 +294,14 @@ public function isOnline(int $uid, bool $cacheOnly=true, ?string $worker=null): return $online ?? $this->getBestWorker($worker)?->isOnline($uid, $cacheOnly); } + public function getBestWorker(?string $worker=null): ?Basic { + $worker ??= $this->mainCharacter ?? array_keys($this->connections)[0]; + if (!isset($this->connections[$worker])) { + $worker = array_keys($this->connections)[0]; + } + return $this->connections[$worker] ?? null; + } + protected function triggerOnReady(): void { $this->isReady = true; $this->logger?->notice("Bot is now fully ready"); @@ -313,14 +321,6 @@ protected function triggerOnReady(): void { } } - private function getBestWorker(?string $worker=null): ?Basic { - $worker ??= $this->mainCharacter ?? array_keys($this->connections)[0]; - if (!isset($this->connections[$worker])) { - $worker = array_keys($this->connections)[0]; - } - return $this->connections[$worker] ?? null; - } - private function workerLoop(WorkerThread $worker): void { while (($package = $worker->client->read()) !== null) { $workerPackage = new WorkerPackage(