Skip to content

Commit

Permalink
use time
Browse files Browse the repository at this point in the history
  • Loading branch information
joedixon committed Nov 22, 2023
1 parent de4c142 commit 75e85b0
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions src/Contracts/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ abstract class Connection
/**
* The last time the connection was seen.
*/
protected ?string $lastSeenAt = null;
protected int $lastSeenAt;

/**
* Stores the ping state of the connection.
Expand All @@ -27,6 +27,7 @@ public function __construct(
protected Application $application,
protected ?string $origin
) {
$this->lastSeenAt = time();
$this->pusher = new PusherEvent;
}

Expand Down Expand Up @@ -83,7 +84,7 @@ public function ping(): void
*/
public function touch(): Connection
{
// $this->lastSeenAt = (string) Carbon::now();
$this->lastSeenAt = time();

return $this;
}
Expand All @@ -96,27 +97,12 @@ public function disconnect(): void
$this->terminate();
}

/**
* Get the last time the connection was seen.
*/
public function lastSeenAt(): ?Carbon
{
return null;
// return $this->lastSeenAt ? Carbon::parse($this->lastSeenAt) : null;
}

/**
* Determine whether the connection is still active.
*/
public function isActive(): bool
{
return true;
// return $this->lastSeenAt() &&
// $this->lastSeenAt()->isAfter(
// Carbon::now()->subMinutes(
// $this->app()->pingInterval()
// )
// );
return time() < $this->lastSeenAt + $this->app()->pingInterval();
}

/**
Expand Down

0 comments on commit 75e85b0

Please sign in to comment.