/** * Send requests and iterate over server responses. * * <p>This returns a live stream that must either be fully consumed or cancelled. */ public BidiStream<RequestT, ResponseT> call(ApiCallContext context) { BidiStream<RequestT, ResponseT> stream = new BidiStream<>(); ClientStream<RequestT> clientStream = splitCall(stream.observer(), context); stream.setClientStream(clientStream); return stream; }
@Test public void bidiStreaming_BidiStream() { BidiStreamingStashCallable<Integer, Integer> callIntList = new BidiStreamingStashCallable<>(Arrays.asList(0, 1, 2)); BidiStreamingCallable<Integer, Integer> callable = FakeCallableFactory.createBidiStreamingCallable( callIntList, StreamingCallSettings.<Integer, Integer>newBuilder().build(), clientContext); BidiStream<Integer, Integer> stream = callIntList.call(); stream.send(3); stream.send(4); stream.send(5); stream.closeSend(); assertThat(callIntList.getActualRequests()).containsExactly(3, 4, 5).inOrder(); assertThat(stream).containsExactly(0, 1, 2).inOrder(); }
/** * Send requests and iterate over server responses. * * <p>This returns a live stream that must either be fully consumed or cancelled. */ public BidiStream<RequestT, ResponseT> call(ApiCallContext context) { BidiStream<RequestT, ResponseT> stream = new BidiStream<>(); ClientStream<RequestT> clientStream = splitCall(stream.observer(), context); stream.setClientStream(clientStream); return stream; }