Add runtime networking APIs
This commit is contained in:
@@ -73,6 +73,25 @@ Image-capable nodes may also use nine-slice scaling with source-pixel insets:
|
||||
|
||||
Nine-slice keeps corners unscaled, stretches edges on one axis, and stretches the center on both axes. Insets are clamped to the selected source region and destination size.
|
||||
|
||||
## Runtime network API
|
||||
|
||||
Lua may use runtime-owned async networking without blocking script execution:
|
||||
|
||||
- `runtime.http_request({ id?, method?, url, headers?, body?, timeout? })`
|
||||
- `runtime.ws_connect({ id?, url, protocols? })`
|
||||
- `runtime.ws_send(id, message)`
|
||||
- `runtime.ws_close(id)`
|
||||
|
||||
HTTP requests support `http` and `https` URLs. WebSocket connections support `ws` and `wss` URLs.
|
||||
|
||||
Network results are delivered back to Lua through `on_event(event)`:
|
||||
|
||||
- `network_http`: HTTP request completed or failed. `event.data` includes `id`, `url`, `method`, `ok`, and either `status`/`headers`/`body` or `error`.
|
||||
- `network_ws_open`: WebSocket connection opened.
|
||||
- `network_ws_message`: WebSocket message received.
|
||||
- `network_ws_error`: WebSocket connection or stream error.
|
||||
- `network_ws_close`: WebSocket connection closed.
|
||||
|
||||
## RuntimeCommand
|
||||
|
||||
Runtime commands request generic side effects owned by Dart/Flame.
|
||||
|
||||
Reference in New Issue
Block a user