Skip to content

Preview documentation

This page has not completed release review. Its SDK or protocol version is not yet a confirmed public release.

Add Gateway Polls and Game Text

Start a poll

private void StartNextLevelPoll()
{
    var poll = new PollConfiguration
    {
        Prompt = "Which level should be next?",
        DurationInSeconds = 30,
        Mode = PollMode.Order
    };

    poll.Options.Add("Ice Cave");
    poll.Options.Add("Desert");
    poll.Options.Add("Jungle");
    poll.OnPollUpdate = update =>
    {
        if (!update.IsFinal)
            return;

        LoadLevel(update.Winner);
    };

    gateway.Client.StartPoll(poll);
}

Treat Winner as an option index and validate it before indexing your own data. Call StopPoll() when the game state invalidates an active poll.

Publish game text

private void PublishGameText(string levelName, string difficulty)
{
    var text = new[]
    {
        new GameText { Label = "Current Level", Value = levelName, Icon = "" },
        new GameText { Label = "Difficulty", Value = difficulty, Icon = "" }
    };

    gateway.Client.SetGameTexts(text);
}

Publish only when values change. Avoid sending text every frame.

Next: Prepare Gateway for production.