/// <summary> /// Executes the specified arguments. /// </summary> /// <param name="args">The arguments.</param> /// <param name="client">The client.</param> /// <param name="closeConnection">The close connection.</param> /// <param name="keepOpen">The keep open.</param> /// <returns></returns> public string Execute(string[] args, TcpClient client, string closeConnection, string keepOpen) { string name = args[0]; NetworkStream stream = client.GetStream(); StreamReader reader = new StreamReader(stream); StreamWriter writer = new StreamWriter(stream); Game game = model.FindGameByClient(client); if (game == null || game.GetMaze().Name != name) { new Controller.NestedError("The game is not in the playing list", client); return(keepOpen); } else { model.DeleteGameFromPlayingGames(name); NetworkStream stream2 = game.GetOpponent(client).GetStream(); StreamReader reader2 = new StreamReader(stream2); StreamWriter writer2 = new StreamWriter(stream2); writer2.WriteLine("exit"); writer2.Flush(); return("exit"); } }
/// <summary> /// Executes the specified arguments. /// </summary> /// <param name="args">The arguments.</param> /// <param name="client">The client.</param> /// <returns></returns> public string Execute(string[] args, TcpClient client, string closeConnection, string keepOpen) { string direction = args[0]; Game game = model.FindGameByClient(client); if (game != null) { NestedPlay play = new NestedPlay(game.GetMaze().Name, direction, game.GetOpponent(client)); } else { new Controller.NestedError("you need to start a game first", client); } return(keepOpen); }