Beispiel #1
0
        public SkillResponse HandleSkillRequest([FromBody] SkillRequest request)
        {
            // Quick security check
            _processor.ValidateRequest(request);

            // Validate we can handle this request
            var requestType = _processor.GetRequestType(request, _logger);

            if (requestType == null)
            {
                throw new InvalidOperationException("Unsupported request");
            }

            // Hand off to game to do magic
            var session   = new AlexaSession(request.Session);
            var arguments = _processor.GetArguments(request, _logger);
            var game      = new ReindeerGame(session, _logger, _questionFactory);

            try
            {
                var response = game.Execute(requestType.Value, arguments);
                return(_responseFactory.CreateSkillResponse(response));
            }
            catch (Exception e)
            {
                _logger.LogLine("Exception processing game: " + e);
                throw;
            }
        }
Beispiel #2
0
        /// <summary>
        /// A simple function that takes a string and does a ToUpper
        /// </summary>
        /// <param name="input"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public SkillResponse FunctionHandler(SkillRequest input, ILambdaContext context)
        {
            var logger = new LambdaLogger(context.Logger);

            // Quick security check
            RequestProcessor.ValidateRequest(input);

            // Validate we can handle this request
            var requestType = RequestProcessor.GetRequestType(input, logger);

            if (requestType == null)
            {
                throw new InvalidOperationException("Unsupported request");
            }

            // Hand off to game to do magic
            var session   = new AlexaSession(input.Session);
            var arguments = RequestProcessor.GetArguments(input, logger);
            var game      = new ReindeerGame(session, logger, QuestionFactory);

            try
            {
                var response = game.Execute(requestType.Value, arguments);
                return(ResponseFactory.CreateSkillResponse(response));
            }
            catch (Exception e)
            {
                context.Logger.LogLine("Exception processing game: " + e);
                throw;
            }
        }