Class: Cybertrain::Stream::Endpoint
- Inherits:
-
Middleware
- Object
- Middleware
- Cybertrain::Stream::Endpoint
- Defined in:
- cybertrain/stream/endpoint.rb
Overview
The realtime endpoint (docs/design.md D36), mounted by
Application#build_stack at Config#stream_path
(/cybertrain/stream) unless that is “”. A GET with s=<token>
(repeatable; sign, what turbo_stream_from writes) and
optionally mode=raw|json is answered as Server-Sent Events: each
message of the token’s streams as an event (id: and data:; with
mode=json also event: <stream> and the data is
{"stream":...,"id":...,"data":...}), a : ping comment after
Config#stream_ping_interval seconds of silence. Last-Event-ID
replays what is still in the table after that id first. A GET with
Upgrade: websocket gets the same messages over a WebSocket
(WebSocketWriter).
Authorisation is the token’s signature: a bad or missing one is a 403 (with no body, nothing read from the database); no session is read. Past Config#stream_max_connections open streams the answer is 503.