Skip to content

Extend HTTP API methods to match current proto and clean up Client#70

Merged
FZambia merged 2 commits intomasterfrom
extend-api-and-cleanup
May 7, 2026
Merged

Extend HTTP API methods to match current proto and clean up Client#70
FZambia merged 2 commits intomasterfrom
extend-api-and-cleanup

Conversation

@FZambia
Copy link
Copy Markdown
Member

@FZambia FZambia commented May 7, 2026

Summary

Bring Client.php in line with Centrifugo's current HTTP API and clean up a few small issues ahead of v6.0.3.

Extended existing methods with new optional parameters from the proto

  • publish / broadcast: tags, idempotency_key, delta, version, version_epoch
  • subscribe: expire_at, info, data, recover_since, override, session
  • unsubscribe: session
  • disconnect: disconnect (code/reason), whitelist, session

All new parameters are positional optional arguments at the end with sensible defaults, and are only included in the JSON payload when set to a non-default value — so existing callers see byte-identical request bodies.

Out of scope (deliberately): adding entirely new RPCs not previously exposed (rpc, refresh, connections, push/device/user-status/etc.). Worth a follow-up.

Drive-by fixes

  • setSafety docblock — @param was incorrectly labelled $caPath.
  • _json_last_error_msg — the function_exists('json_last_error_msg') fallback table was dead code on any PHP version this library supports (composer requires >= 7.0; json_last_error_msg exists since PHP 5.5). Body shrunk to a one-liner; public signature preserved for BC.
  • request()if (!$this->safety) { ... } elseif ($this->safety) { ... } collapsed to plain else.
  • getUrl()rtrim($this->url, '/') so passing a trailing-slash URL like http://host/api/ no longer yields http://host/api//publish.
  • README — "All available API methods" block was missing subscribe and batch.

Test plan

  • Existing tests/ClientTest.php still passes against latest Centrifugo (no call sites changed; new params are optional).
  • Manual sanity check: payloads for default-arg calls of publish / broadcast / subscribe / unsubscribe / disconnect are byte-identical to v6.0.2.
  • Optional: add a test exercising one of the new fields (e.g. tags on publish, session on disconnect).

🤖 Generated with Claude Code

FZambia added 2 commits May 7, 2026 23:15
Extend existing methods with optional parameters introduced in
Centrifugo's HTTP API since this client was last updated:

* publish/broadcast: tags, idempotency_key, delta, version, version_epoch
* subscribe: expire_at, info, data, recover_since, override, session
* unsubscribe: session
* disconnect: disconnect (code/reason), whitelist, session

New parameters are positional optional arguments at the end and only
included in the JSON payload when set, so existing callers see
byte-identical request bodies.

Drive-by fixes:

* setSafety docblock: @param was incorrectly named caPath
* _json_last_error_msg: drop dead PHP < 5.5 fallback (composer requires
  >= 7.0); public signature preserved for BC
* request(): replace pointless elseif (\$this->safety) with else
* getUrl(): rtrim(\$this->url, '/') so a trailing slash on the
  constructor URL doesn't produce a double slash in the request URL
* README: API methods list was missing subscribe and batch
The flag was renamed in Centrifugo and centrifugo/centrifugo:latest now
exits immediately with "unknown flag: --api_insecure", which made the
"Wait for server to be ready" step hang indefinitely.
@FZambia FZambia merged commit 9bcf937 into master May 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant