Ejemplo n.º 1
0
        public void HandleClient(IClientWrapper client)
        {
            Task task = new Task(() => {
                try
                {
                    while (true)
                    {
                        string message = client.Read();
                        if (message == null)
                        {
                            client.Close();
                            break;
                        }
                        long length        = message.Length;
                        CommandMessage cmd = CommandMessage.FromJSONString(message);
                        bool result;
                        string newMessage = m_controller.ExecuteCommand((int)cmd.Type, cmd.Args, out result);
                        if (result)
                        {
                            client.Write(newMessage);
                        }
                    }
                } catch (IOException ex)
                {
                    client.Close();
                }
            });

            task.Start();
        }
Ejemplo n.º 2
0
 public void Disconnect()
 {
     client.Close();
     Connected = false;
 }