Skip to content

Commit

Permalink
Make getBestWorker() public
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadyita committed Mar 5, 2024
1 parent db8f004 commit 77d3c69
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/Client/Multi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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(
Expand Down

0 comments on commit 77d3c69

Please sign in to comment.