VISU - PHP Game Framework

Dispatcher
in package
implements DispatcherInterface

Table of Contents

Interfaces

DispatcherInterface

Properties

$signalHandlers  : array<string, array<string|int, array{: int, : callable}>>
Registered signals
$handlerId  : int
Internal handler ID counter

Methods

__debugInfo()  : array<string, mixed>
Override debug info as this functions has references all over the place.
clear()  : void
Clears all handlers from a key
clearAll()  : void
Clears all signal handlers from the dispatcher This will remove all registered keys
createLimitedSignalQueue()  : SignalQueue<string|int, Signal>
Creates a limited signal queue for the given key This is the same as `createSignalQueue` but the queue is limited to the given size, and drops all signals after that.
createSignalQueue()  : SignalQueue<string|int, Signal>
Creates a signal queue for the given key A signal queue is a special signal handler, that aggregates the recieved signals until the user pops them from the queue, or the queue is flushed.
destroySignalQueue()  : void
Desroys a signal queue and removes the handler bound to it.
dispatch()  : void
Dispatch a given signal to all handlers Calling this method will invoke all handlers that are registered to the given signal key.
getAllSignalHandlers()  : array<string, array<string|int, array{: int, : callable}>>
Get all registered signal handlers
getSignalHandlersByPriority()  : array<string|int, callable>
Get the signal handlers with the given key and sort them by priority
readSignalsFromContainer()  : void
Register available signal handlers from the given container
register()  : int
Register a signal handler You can pass a priority to define the order in which the handlers are called.
unregister()  : void
Remove a signal handler

Properties

$signalHandlers

Registered signals

protected array<string, array<string|int, array{: int, : callable}>> $signalHandlers = []

$handlerId

Internal handler ID counter

private int $handlerId = 0

Methods

__debugInfo()

Override debug info as this functions has references all over the place.

public __debugInfo() : array<string, mixed>
Return values
array<string, mixed>

clear()

Clears all handlers from a key

public clear(string $key) : void
Parameters
$key : string

clearAll()

Clears all signal handlers from the dispatcher This will remove all registered keys

public clearAll() : void

createLimitedSignalQueue()

Creates a limited signal queue for the given key This is the same as `createSignalQueue` but the queue is limited to the given size, and drops all signals after that.

public createLimitedSignalQueue(string $key[, int $size = 1024 ][, int $priority = 0 ]) : SignalQueue<string|int, Signal>

Don't forget to destroy the queue with destroySignalQueue when you are done with it.

Parameters
$key : string
$size : int = 1024

The maximum size of the queue

$priority : int = 0
Return values
SignalQueue<string|int, Signal>

createSignalQueue()

Creates a signal queue for the given key A signal queue is a special signal handler, that aggregates the recieved signals until the user pops them from the queue, or the queue is flushed.

public createSignalQueue(string $key[, int $priority = 0 ]) : SignalQueue<string|int, Signal>

Don't forget to destroy the queue with destroySignalQueue when you are done with it.

Parameters
$key : string
$priority : int = 0
Return values
SignalQueue<string|int, Signal>

dispatch()

Dispatch a given signal to all handlers Calling this method will invoke all handlers that are registered to the given signal key.

public dispatch(string $key, Signal $signal) : void
Parameters
$key : string

The signal key, this is name on which handlers are registered

$signal : Signal

The signal to dispatch

getAllSignalHandlers()

Get all registered signal handlers

public getAllSignalHandlers() : array<string, array<string|int, array{: int, : callable}>>
Return values
array<string, array<string|int, array{: int, : callable}>>

getSignalHandlersByPriority()

Get the signal handlers with the given key and sort them by priority

public getSignalHandlersByPriority(string $key) : array<string|int, callable>
Parameters
$key : string
Return values
array<string|int, callable>

readSignalsFromContainer()

Register available signal handlers from the given container

public readSignalsFromContainer(Container $container) : void
Parameters
$container : Container

register()

Register a signal handler You can pass a priority to define the order in which the handlers are called.

public register(string $key, callable $handler[, int $priority = 0 ][, int|null $id = null ]) : int

The higher the priority the earlier the handler is called.

When passing a ID, you are responsible for ensuring that the ID is unique. This can also be a handy tool if you want a handler to be only registered once for a specifc use case.

Parameters
$key : string
$handler : callable
$priority : int = 0
$id : int|null = null

(optional) The ID of the handler, this acts as an identifier for later.

Return values
int

The handler registration ID, store this int if you want to remove the handler later.

unregister()

Remove a signal handler

public unregister(string $key, int $id) : void
Parameters
$key : string
$id : int

        
On this page

Search results