WARNING: this isn't useful, don't use it
Fuel\Wss is a hookable PHP websocket client that speaks the Pusher protocol over TLS. It is designed to be driven by an external loop, so you can integrate it with Fuel daemons or any custom event loop.
composer install
# If you're using the public demo host, you must provide a valid app key/secret.
FUEL_WSS_APP_KEY=your_app_key FUEL_WSS_APP_SECRET=your_app_secret \
php examples/connect_and_listen.phpThe examples default to wss.vask.dev but use placeholder app credentials. Override settings with
environment variables, or point them at a local Soketi instance.
Fuel\Wss does not own an event loop. Use stream_select() (or your own loop) and call tick() to
drive IO and timers.
$client->connect();
$stream = $client->stream();
while (true) {
$read = $stream === null ? [] : [$stream];
$write = null;
$except = null;
if ($stream !== null) {
stream_select($read, $write, $except, 0, 200000);
}
$client->tick();
}open: websocket handshake finishedmessage: raw JSON stringpusher:*: decoded Pusher eventserror: \Throwable instanceclose: socket closedreconnect_scheduled:(float $delay, float $at)reconnecting:(float $delay)reconnected: reconnect succeededreconnect_failed: \Throwable instance
FUEL_WSS_HOST(defaultwss.vask.dev)FUEL_WSS_PORT(default443)FUEL_WSS_TLS(defaulttrue)FUEL_WSS_ORIGIN(default depends on example; overrides HTTPOriginheader)FUEL_WSS_APP_KEY(defaultapp_key)FUEL_WSS_APP_SECRET(defaultapp_secret)FUEL_WSS_PATH(default/app/{FUEL_WSS_APP_KEY}?protocol=7&client=fuel-wss-php&version=0.1&flash=false)FUEL_WSS_SUBPROTOCOL(defaultpusher)FUEL_WSS_CHANNEL(defaultpresence-fuel-websocket-testfor presence/client demos)FUEL_WSS_EVENT(defaultclient-fuel-test)FUEL_WSS_DURATION(default20seconds)FUEL_WSS_USER_IDandFUEL_WSS_USER_NAME(presence demos only)FUEL_WSS_DEBUG(defaultfalse, deterministic demo only)
Auto reconnect is enabled by default. Configure it via ClientConfig:
$config = new ClientConfig(
host: $host,
port: $port,
useTls: $useTls,
appKey: $appKey,
appSecret: $appSecret,
autoReconnect: true,
reconnectIntervalSeconds: 1.0,
maxReconnectIntervalSeconds: 30.0,
);php examples/connect_and_listen.php- Connects and prints raw messages plus Pusher events.
php examples/presence_demo.php- Subscribes to the presence channel and prints member count changes.
php examples/client_event_listener.php- Listens for client events on a private/presence channel.
php examples/client_event_sender.php- Sends a
client-*event after subscription succeeds.
- Sends a
php examples/deterministic_demo.php- Forks a listener + sender, then verifies presence updates and client event roundtrip.
docker run --rm -p 6001:6001 \
-e SOKETI_DEFAULT_APP_ID=fuel-wss-demo \
-e SOKETI_DEFAULT_APP_KEY=fuel-wss-demo \
-e SOKETI_DEFAULT_APP_SECRET=dev-secret \
-e SOKETI_DEFAULT_APP_ENABLE_CLIENT_MESSAGES=true \
quay.io/soketi/soketi:latest
FUEL_WSS_HOST=127.0.0.1 FUEL_WSS_PORT=6001 FUEL_WSS_TLS=false \
FUEL_WSS_APP_KEY=fuel-wss-demo FUEL_WSS_APP_SECRET=dev-secret \
php examples/presence_demo.phpdocker run --rm -p 6001:6001 \
-e SOKETI_DEFAULT_APP_ID=fuel-wss-demo \
-e SOKETI_DEFAULT_APP_KEY=fuel-wss-demo \
-e SOKETI_DEFAULT_APP_SECRET=dev-secret \
-e SOKETI_DEFAULT_APP_ENABLE_CLIENT_MESSAGES=true \
quay.io/soketi/soketi:latest
FUEL_WSS_HOST=127.0.0.1 FUEL_WSS_PORT=6001 FUEL_WSS_TLS=false \
FUEL_WSS_APP_KEY=fuel-wss-demo FUEL_WSS_APP_SECRET=dev-secret \
php examples/deterministic_demo.phpThe deterministic demo exits with status 0 when the listener receives the client event.