static void ProcessCommand(string command, string[] args) { switch (command) { case "join_room": var room = args[0]; client.JoinRoom(room).ContinueWith(t => ProcessResponse(t.Result)); break; case "login": var name = args.Length > 0 ? args[0] : "user_" + Guid.NewGuid(); client.Login(name).ContinueWith(t => ProcessResponse(t.Result)); break; case "send": client.SendMessage(args[0], args[1]).ContinueWith(t => ProcessResponse(t.Result)); break; case "list_rooms": client.ListRooms().ContinueWith(t => ProcessListRooms(t.Result)); break; case "list_room_users": client.ListRoomUsers(args[0]).ContinueWith(t => ProcessListRoomUsers(t.Result)); break; case "sleep": var timeout = int.Parse(args[0]); Thread.Sleep(timeout); break; case "stat": var stat = client.Stat; Console.WriteLine($"CommandsSend: {stat.CommandsSend}"); Console.WriteLine($"CommandsReceived: {stat.CommandsReceived}"); Console.WriteLine($"BytesSend: {stat.BytesSend}"); Console.WriteLine($"BytesReceived: {stat.BytesReceived}"); break; } }