예제 #1
0
        public override async Task <DialogTurnResult> ContinueDialogAsync(
            DialogContext dc,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            if (dc == null)
            {
                throw new ArgumentNullException(nameof(dc));
            }

            // The activity text contains the player command.
            var command = dc.Context.Activity.Text;

            // Get the actions for the command from the game script.
            var actions = await GetActionsAsync(dc, command);

            if (actions.Any())
            {
                // Map the actions to Bot Framework activities and send them to the client.
                if (!await ExecuteActionsAsync(dc, actions))
                {
                    // If ExecuteActionsAsync returns false, don't send anymore activities
                    // to the client. Control is handed over to a different dialog.
                    return(new DialogTurnResult(DialogTurnStatus.Waiting));
                }
            }
            else
            {
                // If there are no actions; reply with a standard response.
                await dc.Context.SendActivityAsync(_activityFactory.CannedResponse(dc));
            }

            // Send an Idle activity to let the GUI know that we're waiting for user interaction.
            await dc.Context.SendActivityAsync(_activityFactory.Idle(dc));

            return(new DialogTurnResult(DialogTurnStatus.Waiting));
        }