class Connection extends Connection

Traits

Properties

protected int|null $lastSeenAt

The last time the connection was seen.

from  Connection
protected bool $hasBeenPinged

Stores the ping state of the connection.

from  Connection
protected bool $usesControlFrames

Indicates if the connection uses control frames.

from  Connection
protected bool $connectionSlotAcquired

Whether a connection slot was acquired for this connection.

from  Connection
protected bool $disconnecting

Whether this connection is being cleaned up after a transport disconnect.

from  Connection
protected string|null $id

The normalized socket ID.

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
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.

void
markDisconnecting()

Mark the connection as disconnecting (transport closed).

bool
isDisconnecting()

Determine whether the connection is disconnecting.

string
generateId()

Generate a Pusher-compatible socket ID.

Details

in Connection at line 46
__construct(WebSocketConnection $connection, Application $application, string|null $origin)

Create a new connection instance.

Parameters

WebSocketConnection $connection
Application $application
string|null $origin

at line 23
string identifier()

Get the raw socket connection identifier.

Return Value

string

at line 31
string id()

Get the normalized socket ID.

Return Value

string

at line 43
void send(string $message)

Send a message to the connection.

Parameters

string $message

Return Value

void

at line 55
void control(int $opcode = WEBSOCKET_OPCODE_PING)

Send a control frame to the connection.

Parameters

int $opcode

Return Value

void

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

Terminate a connection.

Parameters

int|null $code
string|null $reason

Return Value

void

in Connection at line 82
Application app()

Get the application the connection belongs to.

Return Value

Application

in Connection at line 90
string|null origin()

Get the origin of the connection.

Return Value

string|null

in Connection at line 98
void ping()

Mark the connection as pinged.

Return Value

void

in Connection at line 106
void pong()

Mark the connection as ponged.

Return Value

void

in Connection at line 114
int|null lastSeenAt()

Get the last time the connection was seen.

Return Value

int|null

in Connection at line 122
Connection setLastSeenAt(int $time)

Set the connection last seen at timestamp.

Parameters

int $time

Return Value

Connection

in Connection at line 132
Connection touch()

Touch the connection last seen at timestamp.

Return Value

Connection

in Connection at line 143
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

in Connection at line 151
bool isActive()

Determine whether the connection is still active.

Return Value

bool

in Connection at line 159
bool isInactive()

Determine whether the connection is inactive.

Return Value

bool

in Connection at line 167
bool isStale()

Determine whether the connection is stale.

Return Value

bool

in Connection at line 175
bool usesControlFrames()

Determine whether the connection uses control frames.

Return Value

bool

in Connection at line 183
Connection setUsesControlFrames(bool $usesControlFrames = true)

Mark the connection as using control frames to track activity.

Parameters

bool $usesControlFrames

Return Value

Connection

in Connection at line 193
bool hasAcquiredConnectionSlot()

Whether a connection slot was acquired for this connection.

Return Value

bool

in Connection at line 201
void markConnectionSlotAcquired()

Mark that a connection slot was acquired for this connection.

Return Value

void

in Connection at line 209
void clearConnectionSlotAcquired()

Clear the connection slot acquired flag.

Return Value

void

in Connection at line 217
void markDisconnecting()

Mark the connection as disconnecting (transport closed).

Return Value

void

in Connection at line 225
bool isDisconnecting()

Determine whether the connection is disconnecting.

Return Value

bool

protected string generateId()

Generate a Pusher-compatible socket ID.

Return Value

string