/// <summary> /// Listens for the client to secifify which task is being requested from the echo service /// </summary> /// <param name="request">Includes which task is being requested and any additional information required for the task to be executed</param> /// <returns>A response message</returns> private ServiceBusResponse echoRequest(EchoServiceRequest request) { switch (request.requestType) { case (EchoRequest.AsIsEcho): return(asIsEcho((AsIsEchoRequest)request)); case (EchoRequest.ReverseEcho): return(reverseEcho((ReverseEchoRequest)request)); default: return(new ServiceBusResponse(false, "Error: Invalid Request. Request received was:" + request.requestType.ToString())); } }
public EchoServiceResponse HandleRequest(EchoServiceRequest request) { if (!inited) { Init(); } var intentValue = request.Request.Intent; if (intentValue == null) { return(new EchoServiceResponse { Response = new EchoResponse { OutputSpeech = new EchoSpeech { Type = "PlainText", Text = "" }, ShouldEndSession = true, }, }); } else { var intentFullName = intentValue.Name; Console.WriteLine("REQUEST INTENT " + intentFullName); var ls = listenSource; var li = listenIntents; lastSaid = ""; listenSource = null; listenIntents = null; if (ls != null && li != null && li.Count > 0 && li.Contains(intentFullName)) { Console.WriteLine("CONTINUE SESSION"); var intent = reflectedSkill.ParseIntent(intentValue); ls.SetResult(intent); } else { if (ls != null) { ls.SetCanceled(); ls = null; } Console.WriteLine("START NEW SESSION"); Func <Intent, Task> startFunc; if (startIntents.TryGetValue(intentFullName, out startFunc)) { var intent = reflectedSkill.ParseIntent(intentValue); var startTask = startFunc(intent); } else { listening.Set(); } } Console.WriteLine("LISTENING..."); listening.WaitOne(listenTimeout); Console.WriteLine("DONE LISTENING, RESPONDING: " + lastSaid); return(new EchoServiceResponse { Response = new EchoResponse { OutputSpeech = new EchoSpeech { Type = "PlainText", Text = lastSaid }, ShouldEndSession = listenIntents == null || listenIntents.Count == 0, }, }); } }
public EchoServiceResponse Post([FromBody] EchoServiceRequest request) { //Console.WriteLine("GOT REQUEST " + request.Request.Intent.Name); return(session.HandleRequest(request)); }