CacheChannel
class CacheChannel extends Channel
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. |
Methods
Subscribe to the given channel.
Publish and commit a channel subscription.
Decode subscription data into connection attributes.
Complete side effects for a committed subscription.
Handle channel occupied — dispatch events, check disconnect smoothing.
Publish and commit a channel unsubscription.
Complete side effects for a committed unsubscription.
Handle channel vacated — dispatch events and clean up shared locks.
Dispatch the subscription_count webhook if enabled and not throttled.
Remove this exact channel when no local membership work remains.
Send a message to all connections subscribed to the channel.
Send a message to every selected local connection.
Broadcast a message triggered from an internal source.
Determine if the channel has a cached payload.
Get the cached payload.
Details
in
SerializesChannels at line 16
array
__serialize()
Prepare the channel instance values for serialization.
in
SerializesChannels at line 26
void
__unserialize(array $values)
Restore the channel after serialization.
in
Channel at line 39
__construct(string $name)
Create a new channel instance.
in
Channel at line 47
string
name()
Get the channel name.
in
Channel at line 57
array
connections()
Get all connections for the channel.
in
Channel at line 65
ChannelConnection|null
find(Connection $connection)
Find a connection.
in
Channel at line 73
ChannelConnection|null
findById(string $id)
Find a connection by its ID.
in
Channel at line 83
void
subscribe(Connection $connection, string|null $auth = null, string|null $data = null, string|null $userId = null)
Subscribe to the given channel.
Presence channels pass the userId for global refcount tracking.
in
Channel at line 101
protected SubscriptionResult|null
subscribeToChannel(Connection $connection, array $attributes, string|null $userId = null)
Publish and commit a channel subscription.
in
Channel at line 133
protected array
decodeSubscriptionData(string|null $data)
Decode subscription data into connection attributes.
in
Channel at line 143
protected void
afterSubscribed(Connection $connection, SubscriptionResult $result)
Complete side effects for a committed subscription.
in
Channel at line 155
protected void
handleChannelOccupied(Connection $connection, SharedState $sharedState)
Handle channel occupied — dispatch events, check disconnect smoothing.
in
Channel at line 199
void
unsubscribe(Connection $connection, string|null $userId = null)
Unsubscribe from the given channel.
Presence channels pass the userId for global refcount tracking.
in
Channel at line 213
protected SubscriptionResult|null
unsubscribeFromChannel(Connection $connection, string|null $userId = null)
Publish and commit a channel unsubscription.
in
Channel at line 240
protected void
afterUnsubscribed(Connection $connection, SubscriptionResult $result)
Complete side effects for a committed unsubscription.
in
Channel at line 252
protected void
handleChannelVacated(Connection $connection)
Handle channel vacated — dispatch events and clean up shared locks.
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.
in
Channel at line 327
bool
subscribed(Connection $connection)
Determine if the connection is subscribed to the channel.
in
Channel at line 335
protected void
removeIfIdle(Connection $connection)
Remove this exact channel when no local membership work remains.
at line 19
void
broadcast(array $payload, Connection|null $except = null)
Send a message to all connections subscribed to the channel.
in
Channel at line 366
void
broadcastToAll(array $payload)
Send a broadcast to all connections.
in
Channel at line 379
protected void
sendToConnections(string $message, Connection|null $except = null)
Send a message to every selected local connection.
at line 29
void
broadcastInternally(array $payload, Connection|null $except = null)
Broadcast a message triggered from an internal source.
in
Channel at line 414
array
data()
Get the data associated with the channel.
at line 37
bool
hasCachedPayload()
Determine if the channel has a cached payload.
at line 45
array|null
cachedPayload()
Get the cached payload.