Skip to content

Commit

Permalink
We are always online
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadyita committed Mar 4, 2024
1 parent 90d1c68 commit 91280ce
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Client/Basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class Basic {

private ?string $loggedInChar = null;

private ?int $loggedInUid = null;

public function __construct(
private Connection $connection,
private Parser $parser,
Expand Down Expand Up @@ -188,6 +190,9 @@ public function getNameCache(): array {
* @return bool|null Either true/false if online/offline or null, if the status is unknown
*/
public function isOnline(int $uid, bool $cacheOnly=true): ?bool {
if ($uid === $this->loggedInUid) {
return true;
}
$cachedOnlineStatus = $this->buddylist[$uid] ?? null;
if ($cacheOnly || $cachedOnlineStatus !== null) {
return $cachedOnlineStatus;
Expand Down Expand Up @@ -241,6 +246,7 @@ public function disconnect(): void {

public function login(string $username, string $password, string $character): void {
$this->loggedInChar = null;
$this->loggedInUid = null;
$this->logger?->debug("Logging in with username {$username}", ["username" => $username]);
$this->publicGroups = [];
$this->buddylist = [];
Expand Down Expand Up @@ -319,6 +325,7 @@ public function login(string $username, string $password, string $character): vo
);
}
$this->loggedInChar = $character;
$this->loggedInUid = $uid;
}

/**
Expand Down

0 comments on commit 91280ce

Please sign in to comment.