Connection
abstract class Connection
Properties
| protected int|null | $lastSeenAt | The last time the connection was seen. |
|
| protected bool | $hasBeenPinged | Stores the ping state of the connection. |
|
| protected bool | $usesControlFrames | Indicates if the connection uses control frames. |
|
| protected bool | $established | Whether the Pusher connection handshake completed. |
|
| protected bool | $connectionSlotAcquired | Whether a connection slot was acquired for this connection. |
|
| protected bool | $rateLimiterInitialized | Whether message rate-limiter state was initialized. |
|
| protected bool | $disconnecting | Whether this connection is being cleaned up after a transport disconnect. |
Methods
Create a new connection instance.
Get the raw socket connection identifier.
Get the normalized socket ID.
Send a message to the connection.
Send a control frame to the connection.
Terminate a connection.
Get the application the connection belongs to.
Get the origin of the connection.
Mark the connection as pinged.
Mark the connection as ponged.
Get the last time the connection was seen.
Set the connection last seen at timestamp.
Touch the connection last seen at timestamp.
Disconnect and unsubscribe from all channels.
Determine whether the connection is still active.
Determine whether the connection is inactive.
Determine whether the connection is stale.
Determine whether the connection uses control frames.
Mark the connection as using control frames to track activity.
Determine whether the connection handshake completed.
Mark the connection as established.
Whether a connection slot was acquired for this connection.
Mark that a connection slot was acquired for this connection.
Clear the connection slot acquired flag.
Determine whether rate-limiter state was initialized.
Mark the rate limiter as initialized.
Clear the rate-limiter initialized flag.
Mark the connection as disconnecting (transport closed).
Determine whether the connection is disconnecting.
Details
at line 56
__construct(WebSocketConnection $connection, Application $application, string|null $origin)
Create a new connection instance.
at line 67
abstract string
identifier()
Get the raw socket connection identifier.
at line 72
abstract string
id()
Get the normalized socket ID.
at line 77
abstract void
send(string $message)
Send a message to the connection.
at line 82
abstract void
control(int $opcode = WEBSOCKET_OPCODE_PING)
Send a control frame to the connection.
at line 87
abstract void
terminate(int|null $code = null, string|null $reason = null)
Terminate a connection.
at line 92
Application
app()
Get the application the connection belongs to.
at line 100
string|null
origin()
Get the origin of the connection.
at line 108
void
ping()
Mark the connection as pinged.
at line 116
void
pong()
Mark the connection as ponged.
at line 124
int|null
lastSeenAt()
Get the last time the connection was seen.
at line 132
Connection
setLastSeenAt(int $time)
Set the connection last seen at timestamp.
at line 142
Connection
touch()
Touch the connection last seen at timestamp.
at line 153
void
disconnect(int|null $code = null, string|null $reason = null)
Disconnect and unsubscribe from all channels.
at line 161
bool
isActive()
Determine whether the connection is still active.
at line 169
bool
isInactive()
Determine whether the connection is inactive.
at line 177
bool
isStale()
Determine whether the connection is stale.
at line 185
bool
usesControlFrames()
Determine whether the connection uses control frames.
at line 193
Connection
setUsesControlFrames(bool $usesControlFrames = true)
Mark the connection as using control frames to track activity.
at line 203
bool
isEstablished()
Determine whether the connection handshake completed.
at line 211
void
markEstablished()
Mark the connection as established.
at line 219
bool
hasAcquiredConnectionSlot()
Whether a connection slot was acquired for this connection.
at line 227
void
markConnectionSlotAcquired()
Mark that a connection slot was acquired for this connection.
at line 235
void
clearConnectionSlotAcquired()
Clear the connection slot acquired flag.
at line 243
bool
hasInitializedRateLimiter()
Determine whether rate-limiter state was initialized.
at line 251
void
markRateLimiterInitialized()
Mark the rate limiter as initialized.
at line 259
void
clearRateLimiterInitialized()
Clear the rate-limiter initialized flag.
at line 267
void
markDisconnecting()
Mark the connection as disconnecting (transport closed).
at line 275
bool
isDisconnecting()
Determine whether the connection is disconnecting.