class PresenceCacheChannel extends CacheChannel

Traits

Properties

protected ChannelConnectionManager $connections

The channel connections.

from  Channel
protected int $membershipOperations

The number of membership operations currently publishing shared state.

from  Channel
protected array|null $payload

Data from last event triggered.

from  CacheChannel

Methods

array
__serialize()

Prepare the channel instance values for serialization.

void
__unserialize(array $values)

Restore the channel after serialization.

__construct(string $name)

Create a new channel instance.

from  Channel
string
name()

Get the channel name.

from  Channel
array
connections()

Get all connections for the channel.

from  Channel
find(Connection $connection)

Find a connection.

from  Channel
findById(string $id)

Find a connection by its ID.

from  Channel
void
subscribe(Connection $connection, string|null $auth = null, string|null $data = null, string|null $userId = null)

Subscribe to the given channel.

subscribeToChannel(Connection $connection, array $attributes, string|null $userId = null)

Publish and commit a channel subscription.

from  Channel
array
decodeSubscriptionData(string|null $data)

Decode subscription data into connection attributes.

from  Channel
void
afterSubscribed(Connection $connection, SubscriptionResult $result)

Complete side effects for a committed subscription.

from  Channel
void
handleChannelOccupied(Connection $connection, SharedState $sharedState)

Handle channel occupied — dispatch events, check disconnect smoothing.

from  Channel
void
unsubscribe(Connection $connection, string|null $userId = null)

Unsubscribe from the given channel.

unsubscribeFromChannel(Connection $connection, string|null $userId = null)

Publish and commit a channel unsubscription.

from  Channel
void
afterUnsubscribed(Connection $connection, SubscriptionResult $result)

Complete side effects for a committed unsubscription.

from  Channel
void
handleChannelVacated(Connection $connection)

Handle channel vacated — dispatch events and clean up shared locks.

from  Channel
void
dispatchSubscriptionCountWebhook(Connection $connection, SubscriptionResult $result)

Dispatch the subscription_count webhook if enabled and not throttled.

from  Channel
bool
subscribed(Connection $connection)

Determine if the connection is subscribed to the channel.

from  Channel
void
removeIfIdle(Connection $connection)

Remove this exact channel when no local membership work remains.

from  Channel
void
broadcast(array $payload, Connection|null $except = null)

Send a message to all connections subscribed to the channel.

void
broadcastToAll(array $payload)

Send a broadcast to all connections.

from  Channel
void
sendToConnections(string $message, Connection|null $except = null)

Send a message to every selected local connection.

from  Channel
void
broadcastInternally(array $payload, Connection|null $except = null)

Broadcast a message triggered from an internal source.

array
data()

Get the data associated with the channel.

bool
hasCachedPayload()

Determine if the channel has a cached payload.

array|null
cachedPayload()

Get the cached payload.

bool
verify(Connection $connection, string|null $auth = null, string|null $data = null)

Determine whether the given authentication token is valid.

Details

in SerializesChannels at line 16
array __serialize()

Prepare the channel instance values for serialization.

Return Value

array

in SerializesChannels at line 26
void __unserialize(array $values)

Restore the channel after serialization.

Parameters

array $values

Return Value

void

in Channel at line 39
__construct(string $name)

Create a new channel instance.

Parameters

string $name

in Channel at line 47
string name()

Get the channel name.

Return Value

string

in Channel at line 57
array connections()

Get all connections for the channel.

Return Value

array

in Channel at line 65
ChannelConnection|null find(Connection $connection)

Find a connection.

Parameters

Connection $connection

Return Value

ChannelConnection|null

in Channel at line 73
ChannelConnection|null findById(string $id)

Find a connection by its ID.

Parameters

string $id

Return Value

ChannelConnection|null

void subscribe(Connection $connection, string|null $auth = null, string|null $data = null, string|null $userId = null)

Subscribe to the given channel.

Parameters

Connection $connection
string|null $auth
string|null $data
string|null $userId

Return Value

void

in Channel at line 101
protected SubscriptionResult|null subscribeToChannel(Connection $connection, array $attributes, string|null $userId = null)

Publish and commit a channel subscription.

Parameters

Connection $connection
array $attributes
string|null $userId

Return Value

SubscriptionResult|null

in Channel at line 133
protected array decodeSubscriptionData(string|null $data)

Decode subscription data into connection attributes.

Parameters

string|null $data

Return Value

array

in Channel at line 143
protected void afterSubscribed(Connection $connection, SubscriptionResult $result)

Complete side effects for a committed subscription.

Parameters

Connection $connection
SubscriptionResult $result

Return Value

void

in Channel at line 155
protected void handleChannelOccupied(Connection $connection, SharedState $sharedState)

Handle channel occupied — dispatch events, check disconnect smoothing.

Parameters

Connection $connection
SharedState $sharedState

Return Value

void

void unsubscribe(Connection $connection, string|null $userId = null)

Unsubscribe from the given channel.

Parameters

Connection $connection
string|null $userId

Return Value

void

in Channel at line 213
protected SubscriptionResult|null unsubscribeFromChannel(Connection $connection, string|null $userId = null)

Publish and commit a channel unsubscription.

Parameters

Connection $connection
string|null $userId

Return Value

SubscriptionResult|null

in Channel at line 240
protected void afterUnsubscribed(Connection $connection, SubscriptionResult $result)

Complete side effects for a committed unsubscription.

Parameters

Connection $connection
SubscriptionResult $result

Return Value

void

in Channel at line 252
protected void handleChannelVacated(Connection $connection)

Handle channel vacated — dispatch events and clean up shared locks.

Parameters

Connection $connection

Return Value

void

in Channel at line 292
protected void dispatchSubscriptionCountWebhook(Connection $connection, SubscriptionResult $result)

Dispatch the subscription_count webhook if enabled and not throttled.

Fires on every subscribe/unsubscribe for non-presence channels. Throttled to once per 5 seconds for channels with >100 subscribers.

Parameters

Connection $connection
SubscriptionResult $result

Return Value

void

in Channel at line 327
bool subscribed(Connection $connection)

Determine if the connection is subscribed to the channel.

Parameters

Connection $connection

Return Value

bool

in Channel at line 335
protected void removeIfIdle(Connection $connection)

Remove this exact channel when no local membership work remains.

Parameters

Connection $connection

Return Value

void

in CacheChannel at line 19
void broadcast(array $payload, Connection|null $except = null)

Send a message to all connections subscribed to the channel.

Parameters

array $payload
Connection|null $except

Return Value

void

in Channel at line 366
void broadcastToAll(array $payload)

Send a broadcast to all connections.

Parameters

array $payload

Return Value

void

in Channel at line 379
protected void sendToConnections(string $message, Connection|null $except = null)

Send a message to every selected local connection.

Parameters

string $message
Connection|null $except

Return Value

void

in CacheChannel at line 29
void broadcastInternally(array $payload, Connection|null $except = null)

Broadcast a message triggered from an internal source.

Parameters

array $payload
Connection|null $except

Return Value

void

array data()

Get the data associated with the channel.

Return Value

array

in CacheChannel at line 37
bool hasCachedPayload()

Determine if the channel has a cached payload.

Return Value

bool

in CacheChannel at line 45
array|null cachedPayload()

Get the cached payload.

Return Value

array|null

protected bool verify(Connection $connection, string|null $auth = null, string|null $data = null)

Determine whether the given authentication token is valid.

Parameters

Connection $connection
string|null $auth
string|null $data

Return Value

bool