RequestAsync
RequestAsync is PromptAsync without the flow requirement. Pass a single widget; the SDK renders it as a modal overlay above whatever screen the player is on, awaits exactly one response, then dismisses the modal.
Use this when you want a one-off ask — a quick name input, a yes/no confirmation, a color pick — without authoring a full screen for it.
Signature
Task<InputEvent> RequestAsync( string playerId, Widget widget, TimeSpan timeout, CancellationToken ct = default);
Task<T> RequestAsync<T>( string playerId, Widget widget, TimeSpan timeout, CancellationToken ct = default);Works with or without a FlowAsset. Supported widget types: button, choice_list, text_input, dpad, tap_area.
Example — pick a color
var pick = await manager.RequestAsync<MyAnswer>( playerId: player.Id, widget: WidgetDefinitions.ChoiceList( id: "pick", options: new[] { new ChoiceOption { Id = "red", Label = "Red" }, new ChoiceOption { Id = "blue", Label = "Blue" }, new ChoiceOption { Id = "green", Label = "Green" }, }), timeout: TimeSpan.FromSeconds(20));
Debug.Log($"{player.DisplayName} picked {pick.ChoiceId}");Lifecycle and cancellation
Same lifecycle as PromptAsync:
| End condition | Result |
|---|---|
| Player emits an event from the widget | Returns the InputEvent. |
| Timeout fires | Throws TimeoutException. |
| Player disconnects | Throws OperationCanceledException. |
You cancel via the CancellationToken | Throws OperationCanceledException. |
manager.DisconnectAsync() | Cancels every pending request. |
RequestAsync vs PromptAsync
Both ask one player for one input. The difference is where the input UI comes from:
PromptAsync | RequestAsync | |
|---|---|---|
| Requires a Flow? | Yes | No |
| Where the widget lives | An existing screen in the flow | Inline, one-off |
| What the player sees | Their screen replaced by screenName | A modal overlay over their current screen |
| Restoration | Returns to prior screen automatically | Modal dismisses; underlying screen unchanged |
If you already have a flow with the right screen, use PromptAsync. If you don’t, use RequestAsync.
Pitfalls
- The player needs to be on some screen for the modal to overlay. If they have no current screen (e.g. brand-new join), the modal still renders, but the underlying screen will be blank when dismissed.
- Don’t fire multiple
RequestAsynccalls for the same player concurrently. Same cancellation rule asPromptAsync— the second cancels the first.
Next
- Multi-screen flows: FlowAsset.
- Drawing-canvas gap recovery:
RequestResendAsync.