Skip to content

Commit

Permalink
mark connections as ponged
Browse files Browse the repository at this point in the history
  • Loading branch information
joedixon committed Dec 7, 2023
1 parent dbb279b commit 5ea787d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Contracts/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,21 @@ public function origin(): ?string
}

/**
* Ping the connection to ensure it is still active.
* Mark the connection as pinged.
*/
public function ping(): void
{
$this->hasBeenPinged = true;
}

/**
* Mark the connection as ponged.
*/
public function pong(): void
{
$this->hasBeenPinged = false;
}

/**
* Get the last time the connection was seen.
*/
Expand All @@ -91,6 +99,7 @@ public function setLastSeenAt(int $time): Connection
public function touch(): Connection
{
$this->setLastSeenAt(time());
$this->pong();

return $this;
}
Expand Down

0 comments on commit 5ea787d

Please sign in to comment.