Core\Sse
An event stream from your server to a client, as a browser's EventSource reads it. A request calls startStream to answer with events, or upgrade to start a script that keeps sending after the request ends. Code that did not open the stream calls current to get it, and send writes one event.
Members
6 members.
| Member | Signature |
|---|---|
upgrade | upgrade(string $entry, mixed $arguments = null, mixed $limits = null, ?array<string> $grants = null, ?string $on = null): void |
startStream | startStream(): Core\Sse |
current | current(): Core\Sse |
receive | receive(): ?Core\Sse\Message |
send | send(mixed $data, ?string $event = null, ?string $id = null): void |
setRetryDelay | setRetryDelay(Core\Time\Duration $after): void |
Example apps
These complete apps use this class. You can download and run each one.
- Poll: A live poll with SQLite and server-sent events. Every open page shows each new vote at once, with no extra server and no library.
