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 | $connectionSlotAcquired | Whether a connection slot was acquired for this connection. |
|
| 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.
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.
Mark the connection as disconnecting (transport closed).
Determine whether the connection is disconnecting.
Details
at line 46
__construct(WebSocketConnection $connection, Application $application, string|null $origin)
Create a new connection instance.
at line 57
abstract string
identifier()
Get the raw socket connection identifier.
at line 62
abstract string
id()
Get the normalized socket ID.
at line 67
abstract void
send(string $message)
Send a message to the connection.
at line 72
abstract void
control(int $opcode = WEBSOCKET_OPCODE_PING)
Send a control frame to the connection.
at line 77
abstract void
terminate(int|null $code = null, string|null $reason = null)
Terminate a connection.
at line 82
Application
app()
Get the application the connection belongs to.
at line 90
string|null
origin()
Get the origin of the connection.
at line 98
void
ping()
Mark the connection as pinged.
at line 106
void
pong()
Mark the connection as ponged.
at line 114
int|null
lastSeenAt()
Get the last time the connection was seen.
at line 122
Connection
setLastSeenAt(int $time)
Set the connection last seen at timestamp.
at line 132
Connection
touch()
Touch the connection last seen at timestamp.
at line 143
void
disconnect(int|null $code = null, string|null $reason = null)
Disconnect and unsubscribe from all channels.
at line 151
bool
isActive()
Determine whether the connection is still active.
at line 159
bool
isInactive()
Determine whether the connection is inactive.
at line 167
bool
isStale()
Determine whether the connection is stale.
at line 175
bool
usesControlFrames()
Determine whether the connection uses control frames.
at line 183
Connection
setUsesControlFrames(bool $usesControlFrames = true)
Mark the connection as using control frames to track activity.
at line 193
bool
hasAcquiredConnectionSlot()
Whether a connection slot was acquired for this connection.
at line 201
void
markConnectionSlotAcquired()
Mark that a connection slot was acquired for this connection.
at line 209
void
clearConnectionSlotAcquired()
Clear the connection slot acquired flag.
at line 217
void
markDisconnecting()
Mark the connection as disconnecting (transport closed).
at line 225
bool
isDisconnecting()
Determine whether the connection is disconnecting.