Documentation

WebSocket extends EventDispatcher
in package

The EventDispatcherInterface is the central point of Symfony's event listener system.

Listeners are registered on the manager and events are dispatched through the manager.

Table of Contents

Constants

EVENT_CLOSE  : mixed = 'close'
EVENT_ERROR  : mixed = 'error'
EVENT_NOTIFICATION  : mixed = 'notification'
EVENT_READY  : mixed = 'ready'

Properties

$_connection  : WebSocket
$_connectionDetails  : mixed
$_platform  : Platform
$_ready  : bool
$_responseCallbacks  : array<string|int, mixed>
$_wsToken  : mixed

Methods

__construct()  : mixed
addListener()  : void
Adds an event listener that listens on the specified events.
addSubscriber()  : void
Adds an event subscriber.
close()  : mixed
connect()  : mixed
connection()  : mixed
dispatch()  : T
Dispatches an event to all registered listeners.
getListenerPriority()  : int|null
Gets the listener priority for a specific event.
getListeners()  : array<string|int, array<string|int, callable>|callable>
Gets the listeners of a specific event or all listeners sorted by descending priority.
hasListeners()  : bool
Checks whether an event has any registered listeners.
ready()  : mixed
removeListener()  : void
Removes an event listener from the specified events.
removeSubscriber()  : void
send()  : mixed
sendRequest()  : mixed
_connect()  : mixed
callListeners()  : void
Triggers the listeners of an event.
clear()  : mixed
handleMessages()  : mixed

Constants

EVENT_CLOSE

public mixed EVENT_CLOSE = 'close'

EVENT_ERROR

public mixed EVENT_ERROR = 'error'

EVENT_NOTIFICATION

public mixed EVENT_NOTIFICATION = 'notification'

EVENT_READY

public mixed EVENT_READY = 'ready'

Properties

$_connectionDetails

protected mixed $_connectionDetails

$_responseCallbacks

protected array<string|int, mixed> $_responseCallbacks = []

Methods

addListener()

Adds an event listener that listens on the specified events.

public addListener(string $eventName, callable|array<string|int, mixed> $listener[, int $priority = 0 ]) : void
Parameters
$eventName : string
$listener : callable|array<string|int, mixed>
$priority : int = 0

The higher this value, the earlier an event listener will be triggered in the chain (defaults to 0)

dispatch()

Dispatches an event to all registered listeners.

public dispatch(object $event[, string|null $eventName = null ]) : T
Parameters
$event : object

The event to pass to the event handlers/listeners

$eventName : string|null = null

The name of the event to dispatch. If not supplied, the class of $event should be used instead.

Return values
T —

The passed $event MUST be returned

getListenerPriority()

Gets the listener priority for a specific event.

public getListenerPriority(string $eventName, callable|array<string|int, mixed> $listener) : int|null

Returns null if the event or the listener does not exist.

Parameters
$eventName : string
$listener : callable|array<string|int, mixed>
Return values
int|null

getListeners()

Gets the listeners of a specific event or all listeners sorted by descending priority.

public getListeners([string|null $eventName = null ]) : array<string|int, array<string|int, callable>|callable>
Parameters
$eventName : string|null = null
Return values
array<string|int, array<string|int, callable>|callable>

hasListeners()

Checks whether an event has any registered listeners.

public hasListeners([string|null $eventName = null ]) : bool
Parameters
$eventName : string|null = null
Return values
bool

removeListener()

Removes an event listener from the specified events.

public removeListener(string $eventName, callable|array<string|int, mixed> $listener) : void
Parameters
$eventName : string
$listener : callable|array<string|int, mixed>

send()

public send(string $data) : mixed
Parameters
$data : string

sendRequest()

public sendRequest(ApiRequest $request, mixed $responseCallback) : mixed
Parameters
$request : ApiRequest
$responseCallback : mixed

callListeners()

Triggers the listeners of an event.

protected callListeners(array<string|int, callable> $listeners, string $eventName, object $event) : void

This method can be overridden to add functionality that is executed for each listener.

Parameters
$listeners : array<string|int, callable>

The event listeners

$eventName : string

The name of the event to dispatch

$event : object

The event object to pass to the event handlers/listeners

handleMessages()

protected handleMessages(mixed $msg) : mixed
Parameters
$msg : mixed
On this page

Search results