public void StartChat()
        {
            if (ClientContext.ChatSession.Any<Message>()) ClientContext.ChatSession.Clear();

            MessageRequestProcessor backgroundRequest = new MessageRequestProcessor();

            while (true)
            {
                ClientInputProcessor inputProc = new ClientInputProcessor();
                string message = inputProc.ReadMessageInput();
                if (message == null) continue;

                try
                {
                    using (var client = new ChatServiceClient(m_ChatServiceNode))
                    {
                        if (!client.PutMessage(ClientContext.Token, message))
                        {
                            Console.Clear();
                            Console.WriteLine(UIMessages.SESSION_LOST);
                            Console.WriteLine("Last login was made by '" + ClientContext.Name + "'" + Environment.NewLine);
                            ClientLoginProcessor login = new ClientLoginProcessor();
                            login.Run();
                        }
                    }
                }
                catch (Exception error)
                {
                    Console.Write("\nServer error: ");
                    Console.WriteLine(error.Message + "\n");
                }
            }
        }
        public void RunLogin()
        {
            while (true)
            {
                ClientInputProcessor inputProc = new ClientInputProcessor();
                var name = inputProc.ReadLoginInput();
                if (name == null) continue;

                try
                {
                    using (var client = new LoginServiceClient(m_ChatServiceNode))
                    {
                        var token = client.Login(name);
                        if (token != Guid.Empty)
                        {
                            ClientContext.Name = name;
                            ClientContext.Token = token;
                            Console.Clear();
                            ClientChatProcessor chat = new ClientChatProcessor();
                            chat.StartChat();
                        }
                        else
                        {
                            Console.WriteLine(UIMessages.LOGIN_ERROR);
                            return;
                        }
                    }
                }
                catch (Exception error)
                {
                    Console.Write("\nServer error: ");
                    Console.WriteLine(error.Message + "\n");
                }
            }
        }
        public void Run()
        {
            while (true)
            {
                ClientInputProcessor inputProc = new ClientInputProcessor();
                var command = inputProc.ReadCommandInput();
                if (command == null) continue;

                switch (command)
                {
                    case "log":
                        RunLogin();
                        break;
                    case "reg":
                        RunRegistration();
                        break;
                    default:
                        Console.WriteLine(UIMessages.COMMAND_ERROR);
                        continue;
                }
            }
        }
        public void RunRegistration()
        {
            while (true)
            {
                ClientInputProcessor inputProc = new ClientInputProcessor();
                var regInput = inputProc.ReadRegistrationInput();
                if (regInput == null) continue;

                try
                {
                    using (var client = new RegistrationServiceClient(m_ChatServiceNode))
                    {
                        if (!client.Register(regInput))
                        {
                            Console.WriteLine(UIMessages.REG_FAILURE);
                            return;
                        }
                        else
                        {
                            Console.WriteLine(UIMessages.REG_SUCCESS);
                            return;
                        }
                    }
                }
                catch (Exception error)
                {
                    Console.Write("\nServer error: ");
                    Console.WriteLine(error.Message + "\n");
                    continue;
                }
            }
        }