Add bidirectional host bridge
This commit is contained in:
@@ -92,6 +92,22 @@ Network results are delivered back to Lua through `on_event(event)`:
|
||||
- `network_ws_error`: WebSocket connection or stream error.
|
||||
- `network_ws_close`: WebSocket connection closed.
|
||||
|
||||
## Runtime host bridge
|
||||
|
||||
Flutter host apps may register a `RuntimeHostBridge` when creating `LuaGameWidget` or `FlameLuaGame`.
|
||||
|
||||
Lua-to-Flutter calls:
|
||||
|
||||
- `runtime.host_call({ id?, method, data? })`: async request. Result is delivered to Lua as `host_call_result` with `id`, `method`, `ok`, and either `result` or `error`.
|
||||
- `runtime.host_notify({ method, data? })`: fire-and-forget notification to Flutter host code.
|
||||
|
||||
Flutter-to-Lua calls:
|
||||
|
||||
- `FlameLuaGame.notifyLua(method, data?)`: emits a `host_notify` event into Lua.
|
||||
- `FlameLuaGame.callLua(method, data?, timeout?)`: emits a `host_call` event into Lua and waits for Lua to call `runtime.host_respond({ id, result?, error? })`.
|
||||
|
||||
Host bridge payloads must be JSON-like values: null, bool, number, string, list, or string-keyed map. Unsupported Dart objects are converted to strings.
|
||||
|
||||
## RuntimeCommand
|
||||
|
||||
Runtime commands request generic side effects owned by Dart/Flame.
|
||||
|
||||
Reference in New Issue
Block a user