Ejemplo n.º 1
0
        public void StartMethod(string handlerId)
        {
            var             startCommand = new StartChannelMethodCommand(handlerId);
            IChannelMessage message;

            try
            {
                StartCommandHandler.Handle(startCommand);
                message = new ChannelMessage()
                {
                    Success = true,
                    Message = "ChannelMethod Started"
                };
            }
            catch (HandlerNotFoundException)
            {
                message = new ChannelMessage
                {
                    Success = false,
                    Message = "ChannelMethod Handler not found"
                };
            }
            _logger.LogInfo(message);
            ChannelMessageWriter.Write(message, Context.Response);
        }
Ejemplo n.º 2
0
        private async void OnMessage(object sender, MessageEventArgs messageEventArgs)
        {
            Message message     = messageEventArgs.Message;
            Chat    ChatInfo    = message.Chat;
            string  messageText = message.Text.ToLower();

            SessionManager.Instance.StoreClientSession(ChatInfo.Id);
            ClientSession  clientSession  = SessionManager.Instance.GetClientSession(ChatInfo.Id);
            CommandRequest commandRequest = new CommandRequest(messageText, clientSession);

            AbstractHandler <CommandRequest> defaultCommandHandler = new DefaultCommandHandler(new DefaultTrueCondition());
            AbstractHandler <CommandRequest> startCommandHandler   = new StartCommandHandler(new StartCommandCondition());
            AbstractHandler <CommandRequest> countryCommandHandler = new CountryCommandHandler(new CountryCommandCondition());
            AbstractHandler <CommandRequest> seasonCommandHandler  = new SeasonCommandHandler(new SeasonCommandCondition());
            AbstractHandler <CommandRequest> menuCommandHandler    = new MenuCommandHandler(new MenuCommandCondition());

            startCommandHandler.Successor   = countryCommandHandler;
            countryCommandHandler.Successor = seasonCommandHandler;
            seasonCommandHandler.Successor  = menuCommandHandler;
            menuCommandHandler.Successor    = defaultCommandHandler;

            startCommandHandler.Handle(commandRequest, Instance);
        }