class BroadcastManager implements Factory mixin Broadcaster

Traits

Properties

protected Closure> $releaseCallbacks from  HasPoolProxy
protected array $drivers

The array of resolved broadcast drivers.

protected array $customCreators

The registered custom driver creators.

protected array $poolables

The array of drivers which will be wrapped as pool proxies.

Methods

mixed
createPoolProxy(string $driver, Closure $resolver, PoolDefinition $definition, string $proxyClass)

Create a pool proxy for an immutable definition.

poolDefinition(string $resource, array $poolConfig, array $fingerprintSource)

Build a namespaced pool definition for a pooled resource.

poolFactory()

Get the shared object-pool factory.

setReleaseCallback(string $driver, Closure $callback)

Set the release callback for a pooled driver.

Closure|null
getReleaseCallback(string $driver)

Get the release callback for a pooled driver.

addPoolable(string $driver)

Add a driver to the poolable-driver list.

removePoolable(string $driver)

Remove a driver from the poolable-driver list.

array
getPoolables()

Get the poolable-driver list.

setPoolables(array $poolables)

Set the poolable-driver list.

mixed
getAttributeValue(object $target, string $attributeClass, string|null $property = null, mixed $default = null)

Get a configuration value from an attribute, falling back to a property.

mixed
extractAttributeValue(object $instance)

Extract the value from an attribute instance.

object|null
getAttributeInstance(object $target, string $attributeClass, ReflectionClass|null $declaringClass = null)

Get an instance of the given attribute class from the target class or its parents.

bool
propertyOverridesAttribute(object $target, ReflectionClass $reflection, string|null $property, ReflectionClass $attributeDeclaringClass)

Determine if a property declared on a child class overrides an inherited attribute.

Closure|null
bindCallbackToSelf(Closure $callback)

Bind the provided callback to the class instance.

string|null
resolveConnectionFromQueueRoute(object $queueable)

Resolve the default connection name for a given queueable instance.

string|null
resolveQueueFromQueueRoute(object $queueable)

Resolve the default queue name for a given queueable instance.

queueRoutes()

Get the queue routes manager instance.

__construct(Container $app)

Create a new manager instance.

void
routes(array|null $attributes = null)

Register the routes for handling broadcast channel authentication and sockets.

void
userRoutes(array|null $attributes = null)

Register the routes for handling broadcast user authentication.

void
channelRoutes(array|null $attributes = null)

Register the routes for handling broadcast authentication and sockets.

string|null
socket(Request|null $request = null)

Get the socket ID for the given request.

on(array|Channel|string $channels)

Begin sending an anonymous broadcast to the given channels.

private(string $channel)

Begin sending an anonymous broadcast to the given private channels.

presence(string $channel)

Begin sending an anonymous broadcast to the given presence channels.

event(mixed $event = null)

Begin broadcasting an event.

void
queue(mixed $event)

Queue the given event for broadcast.

bool
mustBeUniqueAndCannotAcquireLock(mixed $event)

Determine if the broadcastable event must be unique and determine if we can acquire the necessary lock.

connection(UnitEnum|string|null $driver = null)

Get a driver instance.

driver(UnitEnum|string|null $name = null)

Get a driver instance.

get(string $name)

Attempt to get the connection from the local cache.

resolve(string $name)

Resolve the given broadcaster with Pool Proxy if need.

doResolve(string|null $name, array $config)

Resolve the given broadcaster.

callCustomCreator(array $config)

Call a custom driver creator.

createReverbDriver(array $config)

Create an instance of the driver.

createPusherDriver(array $config)

Create an instance of the driver.

Pusher
pusher(array $config)

Get a Pusher instance for the given configuration.

createAblyDriver(array $config)

Create an instance of the driver.

AblyRest
ably(array $config)

Get an Ably instance for the given configuration.

createRedisDriver(array $config)

Create an instance of the driver.

createLogDriver(array $config)

Create an instance of the driver.

createNullDriver(array $config)

Create an instance of the driver.

array|null
getConfig(string $name)

Get the connection configuration.

string
getDefaultDriver()

Get the default driver name.

void
setDefaultDriver(UnitEnum|string $name)

Set the default broadcast driver name.

void
purge(UnitEnum|string|null $name = null)

Disconnect the given driver and close its shared resource pool.

extend(string $driver, Closure $callback)

Register a custom driver creator Closure.

mixed
rescue(Closure $callback)

Execute the given callback using "rescue" if possible.

getApplication()

Get the application instance used by the manager.

setApplication(Container $app)

Set the application instance used by the manager.

forgetDrivers()

Forget all of the resolved driver instances.

mixed
__call(string $method, array $parameters)

Dynamically call the default driver instance.

Details

in HasPoolProxy at line 24
protected mixed createPoolProxy(string $driver, Closure $resolver, PoolDefinition $definition, string $proxyClass)

Create a pool proxy for an immutable definition.

Parameters

string $driver
Closure $resolver
PoolDefinition $definition
string $proxyClass

Return Value

mixed

in HasPoolProxy at line 45
protected PoolDefinition poolDefinition(string $resource, array $poolConfig, array $fingerprintSource)

Build a namespaced pool definition for a pooled resource.

Parameters

string $resource
array $poolConfig
array $fingerprintSource

Return Value

PoolDefinition

at line 455
protected Factory poolFactory()

Get the shared object-pool factory.

Return Value

Factory

in HasPoolProxy at line 71
HasPoolProxy setReleaseCallback(string $driver, Closure $callback)

Set the release callback for a pooled driver.

Boot-only. The callback persists on the manager for the worker lifetime and is captured by every subsequently created proxy for the driver.

Parameters

string $driver
Closure $callback

Return Value

HasPoolProxy

in HasPoolProxy at line 81
Closure|null getReleaseCallback(string $driver)

Get the release callback for a pooled driver.

Parameters

string $driver

Return Value

Closure|null

in HasPoolProxy at line 93
HasPoolProxy addPoolable(string $driver)

Add a driver to the poolable-driver list.

Boot-only. The list persists on the manager for the worker lifetime and is consulted on subsequent driver creation. Per-request use races across coroutines and does not affect already-cached drivers.

Parameters

string $driver

Return Value

HasPoolProxy

in HasPoolProxy at line 109
HasPoolProxy removePoolable(string $driver)

Remove a driver from the poolable-driver list.

Boot-only. The list persists on the manager for the worker lifetime and is consulted on subsequent driver creation. Per-request use races across coroutines and does not affect already-cached drivers.

Parameters

string $driver

Return Value

HasPoolProxy

in HasPoolProxy at line 126
array getPoolables()

Get the poolable-driver list.

Return Value

array

in HasPoolProxy at line 138
HasPoolProxy setPoolables(array $poolables)

Set the poolable-driver list.

Boot-only. The list persists on the manager for the worker lifetime and is consulted on subsequent driver creation. Per-request use races across coroutines and does not affect already-cached drivers.

Parameters

array $poolables

Return Value

HasPoolProxy

protected mixed getAttributeValue(object $target, string $attributeClass, string|null $property = null, mixed $default = null)

Get a configuration value from an attribute, falling back to a property.

Parameters

object $target
string $attributeClass
string|null $property
mixed $default

Return Value

mixed

protected mixed extractAttributeValue(object $instance)

Extract the value from an attribute instance.

Parameters

object $instance

Return Value

mixed

protected object|null getAttributeInstance(object $target, string $attributeClass, ReflectionClass|null $declaringClass = null)

Get an instance of the given attribute class from the target class or its parents.

Parameters

object $target
string $attributeClass
ReflectionClass|null $declaringClass

Return Value

object|null

protected bool propertyOverridesAttribute(object $target, ReflectionClass $reflection, string|null $property, ReflectionClass $attributeDeclaringClass)

Determine if a property declared on a child class overrides an inherited attribute.

Parameters

object $target
ReflectionClass $reflection
string|null $property
ReflectionClass $attributeDeclaringClass

Return Value

bool

protected Closure|null bindCallbackToSelf(Closure $callback)

Bind the provided callback to the class instance.

Parameters

Closure $callback

Return Value

Closure|null

Exceptions

ReflectionException

string|null resolveConnectionFromQueueRoute(object $queueable)

Resolve the default connection name for a given queueable instance.

Parameters

object $queueable

Return Value

string|null

string|null resolveQueueFromQueueRoute(object $queueable)

Resolve the default queue name for a given queueable instance.

Parameters

object $queueable

Return Value

string|null

protected QueueRoutes queueRoutes()

Get the queue routes manager instance.

Return Value

QueueRoutes

at line 74
__construct(Container $app)

Create a new manager instance.

Parameters

Container $app

at line 82
void routes(array|null $attributes = null)

Register the routes for handling broadcast channel authentication and sockets.

Parameters

array|null $attributes

Return Value

void

at line 102
void userRoutes(array|null $attributes = null)

Register the routes for handling broadcast user authentication.

Parameters

array|null $attributes

Return Value

void

at line 124
void channelRoutes(array|null $attributes = null)

Register the routes for handling broadcast authentication and sockets.

Alias of "routes" method.

Parameters

array|null $attributes

Return Value

void

at line 132
string|null socket(Request|null $request = null)

Get the socket ID for the given request.

Parameters

Request|null $request

Return Value

string|null

at line 146
AnonymousEvent on(array|Channel|string $channels)

Begin sending an anonymous broadcast to the given channels.

Parameters

array|Channel|string $channels

Return Value

AnonymousEvent

at line 154
AnonymousEvent private(string $channel)

Begin sending an anonymous broadcast to the given private channels.

Parameters

string $channel

Return Value

AnonymousEvent

at line 162
AnonymousEvent presence(string $channel)

Begin sending an anonymous broadcast to the given presence channels.

Parameters

string $channel

Return Value

AnonymousEvent

at line 170
PendingBroadcast event(mixed $event = null)

Begin broadcasting an event.

Parameters

mixed $event

Return Value

PendingBroadcast

at line 181
void queue(mixed $event)

Queue the given event for broadcast.

Parameters

mixed $event

Return Value

void

at line 238
protected bool mustBeUniqueAndCannotAcquireLock(mixed $event)

Determine if the broadcastable event must be unique and determine if we can acquire the necessary lock.

Parameters

mixed $event

Return Value

bool

at line 250
Broadcaster connection(UnitEnum|string|null $driver = null)

Get a driver instance.

Parameters

UnitEnum|string|null $driver

Return Value

Broadcaster

at line 258
Broadcaster driver(UnitEnum|string|null $name = null)

Get a driver instance.

Parameters

UnitEnum|string|null $name

Return Value

Broadcaster

at line 274
protected Broadcaster get(string $name)

Attempt to get the connection from the local cache.

Parameters

string $name

Return Value

Broadcaster

at line 284
protected Broadcaster resolve(string $name)

Resolve the given broadcaster with Pool Proxy if need.

Parameters

string $name

Return Value

Broadcaster

Exceptions

InvalidArgumentException

at line 310
protected Broadcaster doResolve(string|null $name, array $config)

Resolve the given broadcaster.

Parameters

string|null $name
array $config

Return Value

Broadcaster

Exceptions

InvalidArgumentException
RuntimeException

at line 340
protected Broadcaster callCustomCreator(array $config)

Call a custom driver creator.

Parameters

array $config

Return Value

Broadcaster

at line 348
protected Broadcaster createReverbDriver(array $config)

Create an instance of the driver.

Parameters

array $config

Return Value

Broadcaster

at line 356
protected Broadcaster createPusherDriver(array $config)

Create an instance of the driver.

Parameters

array $config

Return Value

Broadcaster

at line 364
Pusher pusher(array $config)

Get a Pusher instance for the given configuration.

Parameters

array $config

Return Value

Pusher

at line 395
protected Broadcaster createAblyDriver(array $config)

Create an instance of the driver.

Parameters

array $config

Return Value

Broadcaster

at line 403
AblyRest ably(array $config)

Get an Ably instance for the given configuration.

Parameters

array $config

Return Value

AblyRest

at line 411
protected Broadcaster createRedisDriver(array $config)

Create an instance of the driver.

Parameters

array $config

Return Value

Broadcaster

at line 427
protected Broadcaster createLogDriver(array $config)

Create an instance of the driver.

Parameters

array $config

Return Value

Broadcaster

at line 435
protected Broadcaster createNullDriver(array $config)

Create an instance of the driver.

Parameters

array $config

Return Value

Broadcaster

at line 443
protected array|null getConfig(string $name)

Get the connection configuration.

Parameters

string $name

Return Value

array|null

at line 463
string getDefaultDriver()

Get the default driver name.

Return Value

string

at line 473
void setDefaultDriver(UnitEnum|string $name)

Set the default broadcast driver name.

Boot-only. Mutates process-global config; per-request use races across coroutines.

Parameters

UnitEnum|string $name

Return Value

void

at line 487
void purge(UnitEnum|string|null $name = null)

Disconnect the given driver and close its shared resource pool.

Boot or tests only, plus operational recovery of broken pooled resources. Other connections sharing the pool transparently acquire a fresh pool on their next operation.

Parameters

UnitEnum|string|null $name

Return Value

void

at line 529
BroadcastManager extend(string $driver, Closure $callback)

Register a custom driver creator Closure.

Boot-only. The callback persists in the singleton's customCreators array for the worker lifetime and applies to every subsequent broadcaster resolution.

Parameters

string $driver
Closure $callback

Return Value

BroadcastManager

at line 546
protected mixed rescue(Closure $callback)

Execute the given callback using "rescue" if possible.

Parameters

Closure $callback

Return Value

mixed

at line 558
Container getApplication()

Get the application instance used by the manager.

Return Value

Container

at line 570
BroadcastManager setApplication(Container $app)

Set the application instance used by the manager.

Tests only. Swaps the singleton's container reference; per-request use races across coroutines and breaks every concurrent request resolving broadcasters through this manager.

Parameters

Container $app

Return Value

BroadcastManager

at line 583
BroadcastManager forgetDrivers()

Forget all of the resolved driver instances.

Boot or tests only. This is cache-only: pooled broadcasters remain shared resources until purged or reclaimed by their idle TTL.

Return Value

BroadcastManager

at line 593
mixed __call(string $method, array $parameters)

Dynamically call the default driver instance.

Parameters

string $method
array $parameters

Return Value

mixed