Signal

Reference for the Signal module: every class and function, with its full signature, parameters and return type. Triggers real-time broadcasts to WebSocket clients through a signal server, resolves the server connection details from a running container, and reports request failures as a typed error.

This page is a pure reference. It documents only what the module's source defines: the service that triggers a broadcast, the lookup that resolves a running signal server, the service data object that carries its connection details, and the error raised when a request to the signal server fails.

Classes
  • SignalService - triggers a real-time broadcast on the signal server for subscribers of a channel.
  • SignalDatabase - resolves the connection details of a running signal container.
  • SignalServiceData - the resolved connection details of a signal server: WebSocket URL, HTTP URL and admin token.
  • SignalTokenError - thrown when a signal server request fails or does not return a successful status.

SignalService

Interact with the signal server. Provides a static function to trigger a broadcast to the WebSocket clients subscribed to a channel id. Frontend session tokens are minted elsewhere, not by this class.

Functions

Trigger

SignalService::Trigger(string $serverUrl, string $adminToken, string $channelIdHex32): void

Triggers a signal to connected WebSocket clients subscribed to this channel id. Sends a PUT to the signal server's admin API with the admin token; subscribers receive a WebSocket text frame equal to the channel id.

NameTypeDescription
$serverUrlstringThe HTTP URL of the signal server (admin API).
$adminTokenstringThe admin authentication token for the signal server.
$channelIdHex32stringOpaque 32-character lowercase hex channel id (same as in the channel token).

Returns void

SignalDatabase

Resolve the connection details of a signal server. Provides a static function that queries the Cloud module for a running signal container and returns its connection details.

Functions

GetServiceData

SignalDatabase::GetServiceData(): SignalServiceData

Gets Signal service data (WebSocket URL, HTTP URL and admin token) by querying the Cloud module for running signal containers, picking one at random. Throws when no running container is found or its admin token is missing.

Returns SignalServiceData The service data object containing the WebSocket URL, HTTP URL and admin token.

SignalServiceData

The resolved connection details of a signal server: its WebSocket URL, HTTP URL and admin token. A plain data object.

Properties

NameTypeDescription
$websocketUrlstringThe WebSocket URL of the signal server.
$httpUrlstringThe HTTP URL of the signal server.
$adminTokenstringThe admin authentication token for the signal server.
Functions

__construct

SignalServiceData::__construct(string $websocketUrl, string $httpUrl, string $adminToken)

Create the service data. Validates that the WebSocket URL and HTTP URL are URLs and that the admin token is a string.

NameTypeDescription
$websocketUrlstringThe WebSocket URL of the signal server.
$httpUrlstringThe HTTP URL of the signal server.
$adminTokenstringThe admin authentication token for the signal server.

SignalTokenError

A custom exception for Signal service token-related errors, thrown when a request to the signal server fails or does not return a successful status. Extends Exception.

Functions

__construct

SignalTokenError::__construct(string $message = "", int $code = 0, Exception $previous = null)

Constructs a new SignalTokenError.

NameTypeDescription
$messagestringThe error message.
$codeintThe error code (default: 0).
$previousException|nullThe previous exception for chaining.