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 = 'close'
- EVENT_ERROR = 'error'
- EVENT_NOTIFICATION = 'notification'
- EVENT_READY = 'ready'
Properties
- $_connection : WebSocket
- $_connectionDetails : mixed
- $_platform : Platform
- $_ready : bool
- $_responseCallbacks : array<string|int, mixed>
- $_wsToken : mixed
- $listeners : mixed
- $optimized : mixed
- $sorted : mixed
Methods
- __construct() : mixed
- addListener() : mixed
- Adds an event listener that listens on the specified events.
- addSubscriber() : mixed
- Adds an event subscriber.
- close() : mixed
- connect() : mixed
- connection() : mixed
- dispatch() : object
- Dispatches an event to all registered listeners.
- getListenerPriority() : int|null
- Gets the listener priority for a specific event.
- getListeners() : array<string|int, mixed>
- 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() : mixed
- Removes an event listener from the specified events.
- removeSubscriber() : mixed
- send() : mixed
- sendRequest() : mixed
- _connect() : mixed
- callListeners() : mixed
- Triggers the listeners of an event.
- clear() : mixed
- doDispatch() : mixed
- handleMessages() : mixed
- optimizeListeners() : array<string|int, mixed>
- Optimizes the internal list of listeners for the given event by priority.
- sortListeners() : mixed
- Sorts the internal list of listeners for the given event by priority.
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
$_connection
protected
WebSocket
$_connection
$_connectionDetails
protected
mixed
$_connectionDetails
$_platform
protected
Platform
$_platform
$_ready
protected
bool
$_ready
$_responseCallbacks
protected
array<string|int, mixed>
$_responseCallbacks
= []
$_wsToken
protected
mixed
$_wsToken
$listeners
private
mixed
$listeners
= []
$optimized
private
mixed
$optimized
$sorted
private
mixed
$sorted
= []
Methods
__construct()
public
__construct(Platform $platform) : mixed
Parameters
- $platform : Platform
addListener()
Adds an event listener that listens on the specified events.
public
addListener(mixed $eventName, mixed $listener[, mixed $priority = 0 ]) : mixed
Parameters
- $eventName : mixed
-
The event to listen on
- $listener : mixed
-
The listener
- $priority : mixed = 0
-
The higher this value, the earlier an event listener will be triggered in the chain (defaults to 0)
addSubscriber()
Adds an event subscriber.
public
addSubscriber(EventSubscriberInterface $subscriber) : mixed
Parameters
- $subscriber : EventSubscriberInterface
close()
public
close() : mixed
connect()
public
connect([Connector $connector = null ]) : mixed
Parameters
- $connector : Connector = null
connection()
public
connection() : mixed
dispatch()
Dispatches an event to all registered listeners.
public
dispatch(mixed $event) : object
Parameters
- $event : mixed
-
The event to pass to the event handlers/listeners
Return values
object —The passed $event MUST be returned
getListenerPriority()
Gets the listener priority for a specific event.
public
getListenerPriority(mixed $eventName, mixed $listener) : int|null
Parameters
- $eventName : mixed
-
The name of the event
- $listener : mixed
-
The listener
Return values
int|null —The event listener priority
getListeners()
Gets the listeners of a specific event or all listeners sorted by descending priority.
public
getListeners([mixed $eventName = null ]) : array<string|int, mixed>
Parameters
- $eventName : mixed = null
-
The name of the event
Return values
array<string|int, mixed> —The event listeners for the specified event, or all event listeners by event name
hasListeners()
Checks whether an event has any registered listeners.
public
hasListeners([mixed $eventName = null ]) : bool
Parameters
- $eventName : mixed = null
-
The name of the event
Return values
bool —true if the specified event has any listeners, false otherwise
ready()
public
ready() : mixed
removeListener()
Removes an event listener from the specified events.
public
removeListener(mixed $eventName, mixed $listener) : mixed
Parameters
- $eventName : mixed
-
The event to remove a listener from
- $listener : mixed
-
The listener to remove
removeSubscriber()
public
removeSubscriber(EventSubscriberInterface $subscriber) : mixed
Parameters
- $subscriber : EventSubscriberInterface
send()
public
send(string $data) : mixed
Parameters
- $data : string
sendRequest()
public
sendRequest(ApiRequest $request, mixed $responseCallback) : mixed
Parameters
- $request : ApiRequest
- $responseCallback : mixed
_connect()
protected
_connect([Connector $connector = null ]) : mixed
Parameters
- $connector : Connector = null
callListeners()
Triggers the listeners of an event.
protected
callListeners(array<string|int, callable> $listeners, string $eventName, object $event) : mixed
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
clear()
protected
clear() : mixed
doDispatch()
protected
doDispatch(mixed $listeners, mixed $eventName, Event $event) : mixed
since Symfony 4.3, use callListeners() instead
Parameters
- $listeners : mixed
- $eventName : mixed
- $event : Event
handleMessages()
protected
handleMessages(mixed $msg) : mixed
Parameters
- $msg : mixed
optimizeListeners()
Optimizes the internal list of listeners for the given event by priority.
private
optimizeListeners(string $eventName) : array<string|int, mixed>
Parameters
- $eventName : string
Return values
array<string|int, mixed>sortListeners()
Sorts the internal list of listeners for the given event by priority.
private
sortListeners(string $eventName) : mixed
Parameters
- $eventName : string