Channel
Channel
The Channel class manages a collection of connections to the Warlock server. The purpose of this class is to
provide a way to trigger events across all connected channels, allowing for communication and coordination between different parts of the application that are using Warlock.
By providing a static method to register connections and trigger events, the Channel class simplifies the process and allows anonymous functions or other callable methods to be executed across all active connections.
Example use from a Closure:
use Hazaar\Warlock\Channel;
use Hazaar\Warlock\Client;
function() {
$client = new Client();
$client->connect();
$client->exec(function(){
Channel::trigger('eventName', 'data');
});
}
Properties
connections
public array $connections
Methods
registerConnection
public registerConnection(Process $process): void
Parameters
Parameter | Type | Description |
---|---|---|
$process | Process |
trigger
Triggers an event on all connected channels.
public trigger(string $event, mixed $data): bool
Iterates through all active connections and triggers the specified event with the provided data. Skips any connections that are not currently connected.
Parameters
Parameter | Type | Description |
---|---|---|
$event | string | the name of the event to trigger |
$data | mixed | optional data to pass along with the event |
Generated by Hazaar API Doc Generator on Wed, 25 Jun 2025 06:07:11 +0000