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
- DEFAULT_REQUEST_TIMEOUT_SEC = 10
DEFAULT_REQUEST_TIMEOUT_SEC:int const
3.2.3. Structures
- HttpReply
- Fields:
status : int - < HTTP status code; 0 when there was no response (connect refused or request timed out).
body : string - < Response body, or “” on no response.
3.2.4. 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. Uses
http_post’s per-request timeout, so a wedged host yields null rather than blocking the body.
- Arguments:
url : string
3.2.5. Send / receive
- receive_imgui_snapshot(transport: Transport ): JsonValue?
Convenience for send_imgui_command(transport, "imgui_snapshot", null) — fetches the full widget snapshot.
- Arguments:
transport : Transport
- send_imgui_command(transport: Transport; action: string; payload: JsonValue? ): JsonValue?
Send one command through transport and return the parsed JSON response.
3.2.6. Awaiting
- 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.
3.2.7. Raw HTTP
- http_get(url: string; timeout_sec: int = DEFAULT_REQUEST_TIMEOUT_SEC ): HttpReply
GET url with a hard per-request timeout. status == 0 means no response (refused / timed out).
- Arguments:
url : string
timeout_sec : int
- http_post(url: string; body: string; timeout_sec: int = DEFAULT_REQUEST_TIMEOUT_SEC ): HttpReply
POST body as application/json to url with a hard per-request timeout.
- Arguments:
url : string
body : string
timeout_sec : int