package org.tinsae.grpc.client;

import org.tinsae.grpc.HelloReply;
import org.tinsae.grpc.HelloRequest;
import org.tinsae.grpc.HelloWorldServiceGrpc;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;

public class HelloWorldClient {

    public static void main(String[] args) {

        ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost",
                8080)
                .usePlaintext()
                .build();

        HelloWorldServiceGrpc.HelloWorldServiceBlockingStub stub = HelloWorldServiceGrpc.newBlockingStub(channel);

        HelloRequest request = HelloRequest.newBuilder().setName("Andrea").build();

        HelloReply response = stub.sayHello(request);

        System.out.println("Response: " + response.getMessage());
    }
}
