Search in sources :

Example 6 with Feature

use of io.grpc.examples.routeguide.Feature in project vertx-examples by vert-x3.

the class Client method listFeatures.

/**
 * Blocking server-streaming example. Calls listFeatures with a rectangle of interest. Prints each
 * response feature as it arrives.
 */
public void listFeatures(int lowLat, int lowLon, int hiLat, int hiLon) {
    System.out.println("*** ListFeatures: lowLat=" + lowLat + " lowLon=" + lowLon + " hiLat=" + hiLat + " hiLon=" + hiLon);
    Rectangle request = Rectangle.newBuilder().setLo(Point.newBuilder().setLatitude(lowLat).setLongitude(lowLon).build()).setHi(Point.newBuilder().setLatitude(hiLat).setLongitude(hiLon).build()).build();
    stub.listFeatures(request, response -> {
        List<Feature> features = new ArrayList<>();
        response.handler(feature -> {
            System.out.println("Result #" + features.size() + ": " + feature);
            features.add(feature);
        });
        // Neede for now as it triggers an NPE if not set
        response.endHandler(v -> {
        /*
Feb 14, 2017 11:08:53 PM io.grpc.internal.SerializingExecutor$TaskRunner run
SEVERE: Exception while executing runnable io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed@6668e779
java.lang.NullPointerException
	at io.vertx.grpc.impl.GrpcReadStreamImpl$1.onCompleted(GrpcReadStreamImpl.java:69)
	at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:390)
	at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:422)
	*/
        });
    });
}
Also used : Rectangle(io.grpc.examples.routeguide.Rectangle) ArrayList(java.util.ArrayList) Feature(io.grpc.examples.routeguide.Feature)

Aggregations

Feature (io.grpc.examples.routeguide.Feature)6 Point (io.grpc.examples.routeguide.Point)4 Rectangle (io.grpc.examples.routeguide.Rectangle)3 RouteNote (io.grpc.examples.routeguide.RouteNote)2 GrpcService (com.weibo.motan.demo.service.GrpcService)1 ManagedChannel (io.grpc.ManagedChannel)1 RouteSummary (io.grpc.examples.routeguide.RouteSummary)1 StreamObserver (io.grpc.stub.StreamObserver)1 Future (io.vertx.core.Future)1 Promise (io.vertx.core.Promise)1 GrpcBidiExchange (io.vertx.grpc.GrpcBidiExchange)1 GrpcReadStream (io.vertx.grpc.GrpcReadStream)1 GrpcWriteStream (io.vertx.grpc.GrpcWriteStream)1 VertxServer (io.vertx.grpc.VertxServer)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 ApplicationContext (org.springframework.context.ApplicationContext)1 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)1