package io.grpc.example.filesystem;


import io.grpc.Channel;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.StatusRuntimeException;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.mastertheboss.filesystem.FileManagerGrpc;
import com.mastertheboss.filesystem.Directory;
import com.mastertheboss.filesystem.FileList;

import io.grpc.inprocess.InProcessChannelBuilder;
import io.grpc.inprocess.InProcessServerBuilder;

public class ExampleClient {
  private static final Logger logger = Logger.getLogger(ExampleClient.class.getName());

  private final FileManagerGrpc.FileManagerBlockingStub blockingStub;

  /** Construct client for accessing HelloWorld server using the existing channel. */
  public ExampleClient(Channel channel) {

    blockingStub = FileManagerGrpc.newBlockingStub(channel);
  }


  public void getFileList(String dir) {

    Directory request = Directory.newBuilder().setName(dir).build();
    FileList response;
    try {
      response = blockingStub.readDir(request);
    } catch (StatusRuntimeException e) {
      logger.log(Level.WARNING, "RPC failed: {0}", e.getStatus());
      return;
    }
    logger.info("Greeting: " + response.getList());
  }


  public static void main(String[] args) throws Exception {
    String dir =  "/home/francesco/";
    // Access a service running on the local machine on port 50051
    String target = "localhost:50051";


    // Create a communication channel to the server, known as a Channel. Channels are thread-safe
    // and reusable. It is common to create channels at the beginning of your application and reuse
    // them until the application shuts down.
    ManagedChannel channel = ManagedChannelBuilder.forTarget(target)

        .usePlaintext()
        .build();
    try {
      ExampleClient client = new ExampleClient(channel);
      client.getFileList(dir);
    } finally {
      channel.shutdownNow().awaitTermination(5, TimeUnit.SECONDS);
    }
  }
}

@@ -707,94 +707,8 @@
 b;%0A%0A
-  /** Construct client for accessing HelloWorld server using the existing channel. */%0A
   pu
@@ -1153,16 +1153,16 @@
 fo(%22
-Greeting
+Response
 : %22 
@@ -1258,393 +1258,245 @@
     
-String dir =  %22/home/francesco/%22;%0A    // Access a service running on the local machine on port 50051%0A    String target = %22localhost:50051%22;%0A%0A%0A    // Create a communication channel to the server, known as a Channel. Channels are thread-safe%0A    // and reusable. It is common to create channels at the beginning of your application and reuse%0A    // them until the application shuts down.
+if (args.length == 0) %7B%0A       System.out.println(%22Proper Usage is: java ExampleClient directory%22);%0A       System.exit(0);%0A    %7D%0A    // Access a service running on the local machine on port 50051%0A    String target = %22localhost:50051%22;%0A%0A%0A
 %0A   
@@ -1696,19 +1696,23 @@
 ileList(
-dir
+args%5B0%5D
 );%0A    %7D

update project