Esempio n. 1
0
        public void Start()
        {
            Init();

            Logger.Info("Available commands:");
            Logger.Info("Send: Message text");
            Logger.Info("SendTo: UserName Message text");
            Logger.Info("GetAll");
            Logger.Info("GetNew");

            //var timer = new MessageCheckerTimerWrapper(userId);
            //timer.Start();

            bool hasCommand;

            do
            {
                Console.ForegroundColor = ConsoleColor.White;
                string commandText = Console.ReadLine();
                hasCommand = !string.IsNullOrEmpty(commandText);
                if (hasCommand)
                {
                    try
                    {
                        MessageCommand command = CommandParser.Parse(commandText);
                        command.UserId = _userId;
                        command.Execute();
                    }
                    catch (ArgumentException)
                    {
                        Logger.Error("Invalid command");
                    }
                    catch (Exception)
                    {
                        Logger.Error("Error occured");
                    }
                }
            }while (hasCommand);

            var logoutCommand = Bootstrapper.Resolve <LogoutUserCommand>();

            logoutCommand.UserId = _userId;
            logoutCommand.Execute();

            //timer.Stop();
        }