3.2. Transport — pluggable lambda-based IPC for imgui commands
Lambda-typed transport for dasImgui live commands. Transport is a
closure (action, payload) → JsonValue?; live_api_transport(url)
returns a transport that POSTs {"name": action, "args": payload} to
<url>/command and parses the JSON response. Users substitute mocks,
in-process buses, or alternative transports without changing call sites.
Wait helpers — await_imgui, await_imgui_frame, send_with_await
— drive client-side polling against the host’s imgui_await endpoint.
Server-side blocking is incompatible with the GLFW-main-thread invariant
(the dispatch handler runs on the same thread that advances frames), so
waits are always client-side; send_with_await dispatches on
await_frames / await_until: "quiescent" / fire_and_forget and
default-polls quiescence otherwise.
3.2.1. Type aliases
- Transport = lambda<(action:string const;var payload:JsonValue? ):JsonValue?>
typedef Transport = lambda<(action:string const;var payload:json::JsonValue? -const):json::JsonValue?> aka Transport
3.2.2. Constants
- DEFAULT_AWAIT_POLL_MS = 0x32
DEFAULT_AWAIT_POLL_MS:uint const
- DEFAULT_AWAIT_TIMEOUT_SEC = 5f
DEFAULT_AWAIT_TIMEOUT_SEC:float const
3.2.3. Transport construction
- live_api_transport(url: string ): Transport
Default transport: POSTs {"name": action, "args": payload} to <url>/command and parses the JSON response. url is captured by value, so the returned lambda is safe to reuse.
- Arguments:
url : string
3.2.4. Send / receive
- send_imgui_command(transport: Transport; action: string; payload: JsonValue? ): JsonValue?
Send one command through transport and return the parsed JSON response.
3.2.5. Uncategorized
- receive_imgui_snapshot(transport: Transport ): JsonValue?
Convenience for send_imgui_command(transport, "imgui_snapshot", null) — fetches the full widget snapshot.
- Arguments:
transport : Transport
- await_imgui(transport: Transport; until: string = "quiescent"; timeout_sec: float = DEFAULT_AWAIT_TIMEOUT_SEC ): bool
Poll imgui_await until value.quiescent flips true; returns true on quiescence, false on timeout.
- Arguments:
transport : Transport
until : string
timeout_sec : float
- await_imgui_frame(transport: Transport; target_frame: int; timeout_sec: float = DEFAULT_AWAIT_TIMEOUT_SEC ): bool
Poll imgui_await until server-side value.frame >= target_frame; reuses the frame: arg so server flips quiescent at the right tick.
- Arguments:
transport : Transport
target_frame : int
timeout_sec : float
- send_with_await(transport: Transport; action: string; payload: JsonValue?; timeout_sec: float = DEFAULT_AWAIT_TIMEOUT_SEC ): JsonValue?
Send action/payload and honor any await_* modifier the server merged into the response.
Dispatches on await_frames / await_until: "quiescent" / fire_and_forget; otherwise default-polls quiescence with timeout_sec.