Skip to content

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 conditionResult
Player emits an event from the widgetReturns the InputEvent.
Timeout firesThrows TimeoutException.
Player disconnectsThrows OperationCanceledException.
You cancel via the CancellationTokenThrows 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:

PromptAsyncRequestAsync
Requires a Flow?YesNo
Where the widget livesAn existing screen in the flowInline, one-off
What the player seesTheir screen replaced by screenNameA modal overlay over their current screen
RestorationReturns to prior screen automaticallyModal 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 RequestAsync calls for the same player concurrently. Same cancellation rule as PromptAsync — the second cancels the first.

Next