Channel
class Channel
Traits
Properties
| protected ChannelConnectionManager | $connections | The channel connections. |
|
| protected SubscriptionResult | $lastSubscriptionResult | The result from the most recent shared state subscribe/unsubscribe call. |
Methods
Create a new channel instance.
Get the channel name.
Get all connections for the channel.
Find a connection by its ID.
Subscribe to the given channel.
Handle channel occupied — dispatch events, check disconnect smoothing.
Get the result from the most recent subscribe/unsubscribe shared state call.
Handle channel vacated — remove from manager, dispatch events, clean up locks.
Dispatch the subscription_count webhook if enabled and not throttled.
Send a message to all connections subscribed to the channel.
Send a broadcast to all connections.
Broadcast a message triggered from an internal source.
Get the data associated with the channel.
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.
at line 36
__construct(string $name)
Create a new channel instance.
at line 44
string
name()
Get the channel name.
at line 54
array
connections()
Get all connections for the channel.
at line 62
ChannelConnection|null
find(Connection $connection)
Find a connection.
at line 70
ChannelConnection|null
findById(string $id)
Find a connection by its ID.
at line 80
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.
at line 102
protected void
handleChannelOccupied(Connection $connection, SharedState $sharedState)
Handle channel occupied — dispatch events, check disconnect smoothing.
at line 146
protected SubscriptionResult
lastSubscriptionResult()
Get the result from the most recent subscribe/unsubscribe shared state call.
Used by presence channel traits to check memberAdded/memberRemoved.
at line 156
void
unsubscribe(Connection $connection, string|null $userId = null)
Unsubscribe from the given channel.
Presence channels pass the userId for global refcount tracking.
at line 176
protected void
handleChannelVacated(Connection $connection)
Handle channel vacated — remove from manager, dispatch events, clean up locks.
at line 218
protected void
dispatchSubscriptionCountWebhook(Connection $connection)
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.
at line 246
bool
subscribed(Connection $connection)
Determine if the connection is subscribed to the channel.
at line 254
void
broadcast(array $payload, Connection|null $except = null)
Send a message to all connections subscribed to the channel.
at line 279
void
broadcastToAll(array $payload)
Send a broadcast to all connections.
at line 294
void
broadcastInternally(array $payload, Connection|null $except = null)
Broadcast a message triggered from an internal source.
at line 302
array
data()
Get the data associated with the channel.