HelPHP

Stream
in package

Tags
class

Stream

Relays JSON-RPC responses/notifications from mcp/message.php to mcp/sse.php for one MCP HTTP+SSE session. Uses Redis pub/sub when Config::REDIS is enabled (same service already used elsewhere for session storage and process tracking), falling back to a lazily-created DB queue table otherwise -- same lazy table-creation pattern utils/job_manager.php already uses for its "jobs" table.

Table of Contents

Methods

poll()  : array<string|int, string>
Fetches and clears pending messages for a session from the DB queue.
publish()  : void
Publishes one JSON-RPC message (already json_encode()'d) to a session.
subscribe_blocking()  : void
Blocks subscribing to the session's Redis channel, calling $on_message($payload_json) for every message published to it.

Methods

poll()

Fetches and clears pending messages for a session from the DB queue.

public static poll(string $session_id) : array<string|int, string>

Only used when Config::REDIS is disabled.

Parameters
$session_id : string
Return values
array<string|int, string> —

payload_json strings, oldest first

publish()

Publishes one JSON-RPC message (already json_encode()'d) to a session.

public static publish(string $session_id, string $payload_json) : void
Parameters
$session_id : string
$payload_json : string

subscribe_blocking()

Blocks subscribing to the session's Redis channel, calling $on_message($payload_json) for every message published to it.

public static subscribe_blocking(string $session_id, callable $on_message) : void

Only used when Config::REDIS is enabled.

Parameters
$session_id : string
$on_message : callable
On this page

Search results