コード例 #1
0
        public static async Task ProcessRequest(string requestType, Func <Task> handler)
        {
            try
            {
                if (requestType.Equals(BuiltInRequest.LaunchRequest) ||
                    requestType.Equals(CustomRequest.NewUserNameIntent) || requestType.Equals(BuiltInRequest.YesIntent) ||
                    !string.IsNullOrWhiteSpace(State.UserName))
                {
                    Logger.Write($"[{requestType}] handling started");
                    await handler();

                    Logger.Write($"[{requestType}] handling completed");
                }
                else
                {
                    Response.SetSpeech(false, false,
                                       SpeechManager.GetAskForUserNameSpeech() + SpeechManager.GetAskForUserNameReprompt(),
                                       SpeechManager.GetAskForUserNameReprompt());
                }
            }
            catch (Exception ex)
            {
                Logger.Write($"Unable to process [{requestType}]");
                Logger.Write($"Exception detail: {ex}");
                Response.SetSpeech(true, false, SpeechManager.GetExceptionSpeech());
            }
        }
コード例 #2
0
        public async Task HandleRequest()
        {
            await RequestProcessManager.ProcessRequest($"{BuiltInRequest.LaunchRequest}", async() =>
            {
                await Task.Run(() =>
                {
                    State.NumPlayed++;
                    State.NumPrompted = 0;

                    if (string.IsNullOrWhiteSpace(State.UserName))
                    {
                        Response.SetSpeech(false, true,
                                           SpeechManager.GetWelcomeSpeech() + SpeechManager.GetAskForUserNameSpeech() + SpeechManager.GetAskForUserNameReprompt(),
                                           SpeechManager.GetAskForUserNameReprompt());
                    }
                    else
                    {
                        if (State.PendingChallanges.Any())
                        {
                            SessionManager.Set(SessionKey.UserMode, UserMode.Answer);
                            Response.SetSession();
                            Response.SetSpeech(false, true,
                                               $"You have one pending challange to face bryan, are you ready to get wasted? ", "");
                        }
                        else if (State.Profiles == null || !State.Profiles.Any() || State.Profiles.Count < 1)
                        {
                            SessionManager.Set(SessionKey.UserMode, UserMode.Profile);
                            Response.SetSession();
                            Response.SetSpeech(false, true,
                                               SpeechManager.GetWelcomeBackSpeech(State.UserName) + SpeechManager.GetFillUpProfileSpeech() + SpeechManager.GetFillUpProfileReprompt(),
                                               SpeechManager.GetFillUpProfileReprompt());
                        }
                        else if (State.Friends == null || !State.Friends.Any() || State.Friends.Count < 1)
                        {
                        }

                        else
                        {
                        }
                        // you have no challanges today. if you want to send one, please add a friend with the sie digit code.
                        // if you dont have a friend, stop now, go out, and make some friends, then comeback. or say random to get to know someone else
                    }
                });
            });
        }