Merged
Conversation
Implements a new `websocket` plugin (libs/websocket/) that mirrors the
existing UDP plugin but uses the WebSocket protocol over TCP. This lets
Ibex stream computed results (e.g. OHLC bars) to browser-based dashboards
without any extra proxy layer.
Plugin functions:
ws_recv(port: Int) -> DataFrame
WebSocket server source. Accepts connections on `port` and returns
one JSON tick row per call. Uses a 200 ms select() timeout so that
the stream event loop can fire wall-clock time-bucket flushes while
idle, returning StreamTimeout between messages.
ws_send(df: DataFrame, port: Int) -> Int
WebSocket server sink. Broadcasts each DataFrame row as a JSON text
frame to all connected clients on `port`. Creates the TCP listener
lazily, so ws_send works standalone without a paired ws_recv.
Implementation highlights:
- Zero third-party dependencies: SHA-1 and Base64 are implemented
inline (header-only, RFC 3174) for the WebSocket opening handshake.
- Full WebSocket framing: encodes server→client frames (unmasked) and
decodes client→server frames (masked), including close and ping/pong
control frames.
- Shared server state per port via a static map so ws_recv and ws_send
cooperate on the same listener socket and client list.
- Non-blocking accept() on the listen socket ensures ws_send never
stalls waiting for new connections.
Also adds three example files under examples/market_stream/:
- market_stream_ws.ibex — UDP ticks → resample → WebSocket OHLC sink
- ws_client.py — stdlib-only Python WebSocket client
- ws_dashboard.html — browser dashboard with auto-reconnect
https://claude.ai/code/session_014KkcPe2ttDpPoJBPTn7ijP
Three additions to docs/index.html: - Hero lead: mention WebSocket servers for browser dashboards alongside the existing stream pipeline description. - Feature card: new "WebSocket streaming" card explaining ws_send, the automatic RFC 6455 handshake, and plain-JS client connection. - Stream tour: second code block below the UDP examples shows the full UDP → resample → ws_send pipeline so visitors see the end-to-end browser-dashboard use-case at a glance. https://claude.ai/code/session_014KkcPe2ttDpPoJBPTn7ijP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.