From 77d3c696781345b7ba2f5cfb2e0a7c7a6bbc21f8 Mon Sep 17 00:00:00 2001 From: Nadyita Date: Tue, 5 Mar 2024 16:24:39 +0100 Subject: [PATCH] Make getBestWorker() public --- src/Client/Multi.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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(