Localzet Server and related projects documentation

Connect and publish events

Connect over WebSocket to /app/{app_key} with query parameter protocol=7, using a standard WebSocket upgrade and JSON text frames. On connection, the server sends pusher:connection_established with a numeric socket_id and activity_timeout of 120 seconds. It answers pusher:ping with pusher:pong.

Supported behavior includes public channels, HMAC-signed private- and presence- subscriptions, unsubscribe, and presence snapshots with member_added / member_removed. Client events prefixed with client- are accepted only when allow_client_events=true, and only on an already-authorized private/presence channel. They are disabled by default.

For a private subscription, the host application first authenticates the user and returns this authorization value:

{app_key}:{hex(HMAC-SHA256(app_secret, socket_id + ":" + channel))}

For a presence subscription, the signature includes the exact JSON string in channel_data:

{app_key}:{hex(HMAC-SHA256(app_secret, socket_id + ":" + channel + ":" + channel_data))}

channel_data must contain a string or integer user_id; optional user_info must be a JSON object. The server verifies the signature, but does not authenticate users or provide an authorization route. Do not trust client-supplied identity data before validating it in the host application. Triangle\Pusher\Signature::channelAuthorization() can calculate the value after the access decision.

Publish server events with a signed HTTP POST /apps/{app_id}/events. The body contains name, either channel or a channels list, and data; each request carries one event and may target up to 100 channels. data may be a JSON value or a string; string values reach subscribers without additional JSON encoding. The signature is HMAC-SHA256 over METHOD + newline + PATH + newline + sorted query, excluding auth_signature; required parameters are auth_key, auth_timestamp, auth_version=1.0, body_md5 of the exact body, and auth_signature. Query values are decoded once; clock skew is limited to 600 seconds. See the Pusher HTTP API and tests for the selected version for the precise format.

Format bounds

Channel names are limited to ASCII [A-Za-z0-9_-=@,.;] and 164 bytes; event names allow ASCII letters, digits, _, -, up to 200 bytes. Names beginning with pusher: or pusher_ are reserved. Messages are limited to at most 10,000 bytes; the HTTP request body is capped at the configured message limit plus 20,000 bytes of overhead (30,000 bytes by default). A connection can subscribe to at most 100 channels.