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

__construct(WebSocketConnection $connection, Application $application, string|null $origin)

Create a new connection instance.

string
identifier()

Get the raw socket connection identifier.

string
id()

Get the normalized socket ID.

void
send(string $message)

Send a message to the connection.

void
control(int $opcode = WEBSOCKET_OPCODE_PING)

Send a control frame to the connection.

void
terminate(int|null $code = null, string|null $reason = null)

Terminate a connection.

app()

Get the application the connection belongs to.

string|null
origin()

Get the origin of the connection.

void
ping()

Mark the connection as pinged.

void
pong()

Mark the connection as ponged.

int|null
lastSeenAt()

Get the last time the connection was seen.

setLastSeenAt(int $time)

Set the connection last seen at timestamp.

touch()

Touch the connection last seen at timestamp.

void
disconnect(int|null $code = null, string|null $reason = null)

Disconnect and unsubscribe from all channels.

bool
isActive()

Determine whether the connection is still active.

bool
isInactive()

Determine whether the connection is inactive.

bool
isStale()

Determine whether the connection is stale.

bool
usesControlFrames()

Determine whether the connection uses control frames.

setUsesControlFrames(bool $usesControlFrames = true)

Mark the connection as using control frames to track activity.

bool
isEstablished()

Determine whether the connection handshake completed.

void
markEstablished()

Mark the connection as established.

bool
hasAcquiredConnectionSlot()

Whether a connection slot was acquired for this connection.

void
markConnectionSlotAcquired()

Mark that a connection slot was acquired for this connection.

void
clearConnectionSlotAcquired()

Clear the connection slot acquired flag.

bool
hasInitializedRateLimiter()

Determine whether rate-limiter state was initialized.

void
markRateLimiterInitialized()

Mark the rate limiter as initialized.

void
clearRateLimiterInitialized()

Clear the rate-limiter initialized flag.

void
markDisconnecting()

Mark the connection as disconnecting (transport closed).

bool
isDisconnecting()

Determine whether the connection is disconnecting.

Details

at line 56
__construct(WebSocketConnection $connection, Application $application, string|null $origin)

Create a new connection instance.

Parameters

WebSocketConnection $connection
Application $application
string|null $origin

at line 67
abstract string identifier()

Get the raw socket connection identifier.

Return Value

string

at line 72
abstract string id()

Get the normalized socket ID.

Return Value

string

at line 77
abstract void send(string $message)

Send a message to the connection.

Parameters

string $message

Return Value

void

at line 82
abstract void control(int $opcode = WEBSOCKET_OPCODE_PING)

Send a control frame to the connection.

Parameters

int $opcode

Return Value

void

at line 87
abstract void terminate(int|null $code = null, string|null $reason = null)

Terminate a connection.

Parameters

int|null $code
string|null $reason

Return Value

void

at line 92
Application app()

Get the application the connection belongs to.

Return Value

Application

at line 100
string|null origin()

Get the origin of the connection.

Return Value

string|null

at line 108
void ping()

Mark the connection as pinged.

Return Value

void

at line 116
void pong()

Mark the connection as ponged.

Return Value

void

at line 124
int|null lastSeenAt()

Get the last time the connection was seen.

Return Value

int|null

at line 132
Connection setLastSeenAt(int $time)

Set the connection last seen at timestamp.

Parameters

int $time

Return Value

Connection

at line 142
Connection touch()

Touch the connection last seen at timestamp.

Return Value

Connection

at line 153
void disconnect(int|null $code = null, string|null $reason = null)

Disconnect and unsubscribe from all channels.

Parameters

int|null $code
string|null $reason

Return Value

void

at line 161
bool isActive()

Determine whether the connection is still active.

Return Value

bool

at line 169
bool isInactive()

Determine whether the connection is inactive.

Return Value

bool

at line 177
bool isStale()

Determine whether the connection is stale.

Return Value

bool

at line 185
bool usesControlFrames()

Determine whether the connection uses control frames.

Return Value

bool

at line 193
Connection setUsesControlFrames(bool $usesControlFrames = true)

Mark the connection as using control frames to track activity.

Parameters

bool $usesControlFrames

Return Value

Connection

at line 203
bool isEstablished()

Determine whether the connection handshake completed.

Return Value

bool

at line 211
void markEstablished()

Mark the connection as established.

Return Value

void

at line 219
bool hasAcquiredConnectionSlot()

Whether a connection slot was acquired for this connection.

Return Value

bool

at line 227
void markConnectionSlotAcquired()

Mark that a connection slot was acquired for this connection.

Return Value

void

at line 235
void clearConnectionSlotAcquired()

Clear the connection slot acquired flag.

Return Value

void

at line 243
bool hasInitializedRateLimiter()

Determine whether rate-limiter state was initialized.

Return Value

bool

at line 251
void markRateLimiterInitialized()

Mark the rate limiter as initialized.

Return Value

void

at line 259
void clearRateLimiterInitialized()

Clear the rate-limiter initialized flag.

Return Value

void

at line 267
void markDisconnecting()

Mark the connection as disconnecting (transport closed).

Return Value

void

at line 275
bool isDisconnecting()

Determine whether the connection is disconnecting.

Return Value

bool