/// <summary> /// Executes the specified arguments. /// </summary> /// <param name="args">The arguments.</param> /// <param name="ch">The ch.</param> /// <param name="client">The client.</param> /// <returns>string of list command</returns> public override string Execute(string[] args, ClientOfServer client = null) { string list = JsonConvert.SerializeObject(model.List()); client.WriteToClient(list); client.DisconnectFromServer(); return(list); }
/// <summary> /// Executes the specified arguments to start. /// </summary> /// <param name="args">The arguments.</param> /// <param name="ch">The ch.</param> /// <param name="client">The client.</param> /// <returns>string of the solve maze</returns> public override string Execute(string[] args, ClientOfServer client = null) { string name = args[0]; int typeSolve = int.Parse(args[1]); MazeSolution s = model.Solve(name, typeSolve); client.WriteToClient(s.ToJSON()); client.DisconnectFromServer(); return(s.ToJSON()); }
/// <summary> /// Executes the specified arguments Generate Maze Command. /// </summary> /// <param name="args">The arguments.</param> /// <param name="ch">The ch.</param> /// <param name="client">The client.</param> /// <returns></returns> public override string Execute(string[] args, ClientOfServer client = null) { string name = args[0]; int rows = int.Parse(args[1]); int cols = int.Parse(args[2]); Maze maze = model.GenerateMaze(name, rows, cols); client.WriteToClient(maze.ToJSON()); client.DisconnectFromServer(); return(maze.ToJSON()); }
/// <summary> /// Executes the specified arguments abstract method. /// </summary> /// <param name="args">The arguments.</param> /// <param name="ch">The ch.</param> /// <param name="client">The client.</param> /// <returns> /// string of the command /// </returns> public override string Execute(string[] args, ClientOfServer client = null) { string name = args[0]; ClientOfServer otherPlayer = model.Close(name, client); if (otherPlayer != null) { otherPlayer.DisconnectFromServer(); } client.DisconnectFromServer(); return(null); }
/// <summary> /// Executes the specified arguments abstract method. /// </summary> /// <param name="args">The arguments.</param> /// <param name="ch">The ch.</param> /// <param name="client">The client.</param> /// <returns> /// string of the command /// </returns> public override string Execute(string[] args, ClientOfServer client = null) { string name = args[0]; //JObject obj = new JObject(); //obj["close"] = "game-over"; ClientOfServer otherPlayer = model.Close(client); //using (NetworkStream stream = otherPlayer.GetStream()) //using (StreamWriter writer = new StreamWriter(stream)) //{ // writer.AutoFlush = true; // writer.Write(obj.ToString()); //} otherPlayer.DisconnectFromServer(); client.DisconnectFromServer(); //return obj.ToString(); return(null); }