Пример #1
0
        public void Process()
        {
            try
            {
                string fisrtMessage = GetMessage();
                if (!fisrtMessage.Contains("Test:Test"))
                {
                    Disconnect();
                    return;
                }
                SendMessage("Hi");
                while (true)
                {
                    string request = GetMessage();
                    if (request.Contains("Quit"))
                    {
                        Disconnect();
                    }
                    if (request != "")
                    {
                        Console.WriteLine("New request: " + request);
                    }

                    CommandObject command  = new CommandObject(request);
                    string        response = cmdHolder.DoCommand(command).Result;
                    SendMessage(response);
                }
            }
            catch (Exception e)
            {
                if (e.HResult == -2146233040)
                {
                    return;
                }
                Disconnect();
                return;
            }
        }