class AblyBroadcaster extends Broadcaster (View source)

Properties

protected Closure|null $authenticatedUserCallback

The callback to resolve the authenticated user information.

from  Broadcaster
protected array $channels

The registered channel authenticators.

from  Broadcaster
protected array $channelOptions

The registered channel options.

from  Broadcaster
protected BindingRegistrar $bindingRegistrar

The binding registrar instance.

from  Broadcaster
protected AblyRest $ably

The AblyRest SDK instance.

Methods

array|null
resolveAuthenticatedUser(Request $request)

Resolve the authenticated user payload for the incoming connection request.

void
resolveAuthenticatedUserUsing(Closure $callback)

Register the user retrieval callback used to authenticate connections.

$this
channel(HasBroadcastChannel|string $channel, callable|string $callback, array $options = [])

Register a channel authenticator.

mixed
verifyUserCanAccessChannel(Request $request, string $channel)

Authenticate the incoming request for a given channel.

array
extractAuthParameters(string $pattern, string $channel, callable|string $callback)

Extract the parameters from the given pattern and channel.

extractParameters(callable|string $callback)

Extracts the parameters out of what the user passed to handle the channel authentication.

extractParametersFromClass(string $callback)

Extracts the parameters out of a class channel's "join" method.

array
extractChannelKeys(string $pattern, string $channel)

Extract the channel keys from the incoming channel name.

mixed
resolveBinding(string $key, string $value, array $callbackParameters)

Resolve the given parameter binding.

mixed
resolveExplicitBindingIfPossible(string $key, mixed $value)

Resolve an explicit parameter binding if applicable.

mixed
resolveImplicitBindingIfPossible(string $key, mixed $value, array $callbackParameters)

Resolve an implicit parameter binding if applicable.

bool
isImplicitlyBindable(string $key, ReflectionParameter $parameter)

Determine if a given key and parameter is implicitly bindable.

array
formatChannels(array $channels)

Format the channel array into an array of strings.

binder()

Get the model binding registrar instance.

callable
normalizeChannelHandlerToCallable(mixed $callback)

Normalize the given callback into a callable.

mixed
retrieveUser(Request $request, string $channel)

Retrieve the authenticated user using the configured guard (if any).

array
retrieveChannelOptions(string $channel)

Retrieve options for a certain channel.

bool
channelNameMatchesPattern(string $channel, string $pattern)

Check if the channel name from the request matches a pattern from registered channels.

getChannels()

Get all of the registered channels.

void
__construct(AblyRest $ably)

Create a new broadcaster instance.

mixed
auth(Request $request)

Authenticate the incoming request for a given channel.

mixed
validAuthenticationResponse(Request $request, mixed $result)

Return the valid authentication response.

string
generateAblySignature(string $channelName, string $socketId, array|null $userData = null)

Generate the signature needed for Ably authentication headers.

void
broadcast(array $channels, string $event, array $payload = [])

Broadcast the given event.

Message
buildAblyMessage(string $event, array $payload = [])

Build an Ably message object for broadcasting.

bool
isGuardedChannel(string $channel)

Return true if the channel is protected by authentication.

string
normalizeChannelName(string $channel)

Remove prefix from channel name.

string
getPublicToken()

Get the public token value from the Ably key.

string
getPrivateToken()

Get the private token value from the Ably key.

AblyRest
getAbly()

Get the underlying Ably SDK instance.

void
setAbly(AblyRest $ably)

Set the underlying Ably SDK instance.

Details

array|null resolveAuthenticatedUser(Request $request)

Resolve the authenticated user payload for the incoming connection request.

See: https://pusher.com/docs/channels/library_auth_reference/auth-signatures/#user-authentication.

Parameters

Request $request

Return Value

array|null

void resolveAuthenticatedUserUsing(Closure $callback)

Register the user retrieval callback used to authenticate connections.

See: https://pusher.com/docs/channels/library_auth_reference/auth-signatures/#user-authentication.

Parameters

Closure $callback

Return Value

void

$this channel(HasBroadcastChannel|string $channel, callable|string $callback, array $options = [])

Register a channel authenticator.

Parameters

HasBroadcastChannel|string $channel
callable|string $callback
array $options

Return Value

$this

protected mixed verifyUserCanAccessChannel(Request $request, string $channel)

Authenticate the incoming request for a given channel.

Parameters

Request $request
string $channel

Return Value

mixed

Exceptions

AccessDeniedHttpException

protected array extractAuthParameters(string $pattern, string $channel, callable|string $callback)

Extract the parameters from the given pattern and channel.

Parameters

string $pattern
string $channel
callable|string $callback

Return Value

array

protected ReflectionParameter[] extractParameters(callable|string $callback)

Extracts the parameters out of what the user passed to handle the channel authentication.

Parameters

callable|string $callback

Return Value

ReflectionParameter[]

Exceptions

Exception

protected ReflectionParameter[] extractParametersFromClass(string $callback)

Extracts the parameters out of a class channel's "join" method.

Parameters

string $callback

Return Value

ReflectionParameter[]

Exceptions

Exception

protected array extractChannelKeys(string $pattern, string $channel)

Extract the channel keys from the incoming channel name.

Parameters

string $pattern
string $channel

Return Value

array

protected mixed resolveBinding(string $key, string $value, array $callbackParameters)

Resolve the given parameter binding.

Parameters

string $key
string $value
array $callbackParameters

Return Value

mixed

protected mixed resolveExplicitBindingIfPossible(string $key, mixed $value)

Resolve an explicit parameter binding if applicable.

Parameters

string $key
mixed $value

Return Value

mixed

protected mixed resolveImplicitBindingIfPossible(string $key, mixed $value, array $callbackParameters)

Resolve an implicit parameter binding if applicable.

Parameters

string $key
mixed $value
array $callbackParameters

Return Value

mixed

Exceptions

AccessDeniedHttpException

protected bool isImplicitlyBindable(string $key, ReflectionParameter $parameter)

Determine if a given key and parameter is implicitly bindable.

Parameters

string $key
ReflectionParameter $parameter

Return Value

bool

protected array formatChannels(array $channels)

Format the channel array into an array of strings.

Parameters

array $channels

Return Value

array

protected BindingRegistrar binder()

Get the model binding registrar instance.

Return Value

BindingRegistrar

protected callable normalizeChannelHandlerToCallable(mixed $callback)

Normalize the given callback into a callable.

Parameters

mixed $callback

Return Value

callable

protected mixed retrieveUser(Request $request, string $channel)

Retrieve the authenticated user using the configured guard (if any).

Parameters

Request $request
string $channel

Return Value

mixed

protected array retrieveChannelOptions(string $channel)

Retrieve options for a certain channel.

Parameters

string $channel

Return Value

array

protected bool channelNameMatchesPattern(string $channel, string $pattern)

Check if the channel name from the request matches a pattern from registered channels.

Parameters

string $channel
string $pattern

Return Value

bool

Collection getChannels()

Get all of the registered channels.

Return Value

Collection

void __construct(AblyRest $ably)

Create a new broadcaster instance.

Parameters

AblyRest $ably

Return Value

void

mixed auth(Request $request)

Authenticate the incoming request for a given channel.

Parameters

Request $request

Return Value

mixed

Exceptions

AccessDeniedHttpException

mixed validAuthenticationResponse(Request $request, mixed $result)

Return the valid authentication response.

Parameters

Request $request
mixed $result

Return Value

mixed

string generateAblySignature(string $channelName, string $socketId, array|null $userData = null)

Generate the signature needed for Ably authentication headers.

Parameters

string $channelName
string $socketId
array|null $userData

Return Value

string

void broadcast(array $channels, string $event, array $payload = [])

Broadcast the given event.

Parameters

array $channels
string $event
array $payload

Return Value

void

Exceptions

BroadcastException

protected Message buildAblyMessage(string $event, array $payload = [])

Build an Ably message object for broadcasting.

Parameters

string $event
array $payload

Return Value

Message

bool isGuardedChannel(string $channel)

Return true if the channel is protected by authentication.

Parameters

string $channel

Return Value

bool

string normalizeChannelName(string $channel)

Remove prefix from channel name.

Parameters

string $channel

Return Value

string

protected string getPublicToken()

Get the public token value from the Ably key.

Return Value

string

protected string getPrivateToken()

Get the private token value from the Ably key.

Return Value

string

AblyRest getAbly()

Get the underlying Ably SDK instance.

Return Value

AblyRest

void setAbly(AblyRest $ably)

Set the underlying Ably SDK instance.

Parameters

AblyRest $ably

Return Value

void