/// <summary> /// executing a command and back an answer /// </summary> /// <param name="server">the server of the service</param> /// <param name="commandAndArg">the command and the args of this command</param> /// <param name="writer">the writer to the client</param> /// <param name="client">the client that need to remove if the connection is failed</param> private void ExecuteCommand(ImageServer server, string[] commandAndArg, BinaryWriter writer, TcpClient client) { List <TcpClient> clients = server.GetClients(); bool resultSuccesful; string result; string[] args = new string[1]; args[0] = " "; result = server.GetController().ExecuteCommand(Convert.ToInt32((Enum.Parse(typeof(CommandEnum), commandAndArg[0]))), args, out resultSuccesful); try { writer.Write(result); } catch (Exception) { this.RemoveClient(clients, client); } }