private void UnregisterUser() { if (Player == null) { Console.WriteLine("You are not registered"); return; } string jsonRequest = JsonConvert.SerializeObject(new Packet(Command.UNREGISTER_USER, true)); WritePacket(socket, jsonRequest); Packet packet = ReadPacket(socket); if (packet.Success) { Player = null; DebugUtils.WriteLine("[CLIENT] Account Deactivated"); MenuUtils.ShowUnregisteredMenu(); } else { DebugUtils.WriteLine("[CLIENT] Error in deactivating a user's account"); } }
public void Run() { try { ConnectToServers(); MenuUtils.ShowUnregisteredMenu(); while (true) { Command command = GetUserMenuInput(); switch (command) { case Command.REGISTER_USER: RegisterUser(); break; case Command.CHANGE_NAME: ChangeName(); break; case Command.UNREGISTER_USER: UnregisterUser(); break; case Command.SHOW_GAMES: ShowGames(); break; case Command.JOIN_GAME: JoinGame(); break; case Command.CREATE_GAME: CreateGame(); break; case Command.VIEW_LEADERBOARD: ViewLeaderboard(); break; case Command.CHEAT_CODE: CheatCode(); break; case Command.CLOSE_SOCKET: CloseSocket(); return; } } } catch (SocketException) { Console.WriteLine("Could not connect to any servers. Please try again later."); Console.ReadLine(); } catch (Exception e) { Console.WriteLine($"[!] Error {e.GetType().Name}\n {e.StackTrace} \nPress any key to exit..."); Console.ReadLine(); } }