public void Process() { try { OnConnect(); } catch (Exception e) { Console.WriteLine(e); Server.RemoveConnection(this.Id); Close(); return; } while (true) { try { var message = GetMessage(); var command = CreateCommand(message); command.Execute(Server.Context, Id); if (message.Length < 2) { throw new Exception("Short message"); } Console.WriteLine($"source = {((IPEndPoint)_client.Client.LocalEndPoint).Address}, command = {command.Type}"); } catch (Exception e) { Console.WriteLine(e); break; } } Close(); Server.RemoveConnection(Id); }