@Test public void testClientServer() throws Exception { RpcServer server = autoClose(new RpcServer(emptyConfig)); Rpc[] rpcs = createRpcConnection(server); Rpc serverRpc = rpcs[0]; Rpc client = rpcs[1]; TestMessage outbound = new TestMessage("Hello World!"); Future<TestMessage> call = client.call(outbound, TestMessage.class); TestMessage reply = call.get(10, TimeUnit.SECONDS); assertEquals(outbound.message, reply.message); TestMessage another = new TestMessage("Hello again!"); Future<TestMessage> anotherCall = client.call(another, TestMessage.class); TestMessage anotherReply = anotherCall.get(10, TimeUnit.SECONDS); assertEquals(another.message, anotherReply.message); String errorMsg = "This is an error."; try { client.call(new ErrorCall(errorMsg)).get(10, TimeUnit.SECONDS); } catch (ExecutionException ee) { assertTrue(ee.getCause() instanceof RpcException); assertTrue(ee.getCause().getMessage().indexOf(errorMsg) >= 0); } TestMessage serverMsg = new TestMessage("Hello from the server!"); Future<TestMessage> serverCall = serverRpc.call(serverMsg, TestMessage.class); TestMessage serverReply = serverCall.get(10, TimeUnit.SECONDS); assertEquals(serverMsg.message, serverReply.message); }
public Future<Void> call(Object msg) { return call(msg, Void.class); }
Rpc implements Closeable { public Future<Void> call(Object msg) { return call(msg, Void.class); } }
Rpc implements Closeable { public Future<Void> call(Object msg) { return call(msg, Void.class); } private  Rpc(RpcConfiguration config, Channel channel, EventExecutorGroup egroup); }
Rpc implements Closeable { public Future<Void> call(Object msg) { return call(msg, Void.class); } private  Rpc(RpcConfiguration config, Channel channel, EventExecutorGroup egroup); static Promise<Rpc> createClient(
      Map<String, String> config,
      final NioEventLoopGroup eloop,
      String host,
      int port,
      final String clientId,
      final String secret,
      final RpcDispatcher dispatcher); void addListener(Listener l); Future<Void> call(Object msg); Future<T> call(Object msg, Class<T> retType); Promise<T> createPromise(); @Override void close(); }
Rpc implements Closeable { public Future<Void> call(Object msg) { return call(msg, Void.class); } private  Rpc(RpcConfiguration config, Channel channel, EventExecutorGroup egroup); static Promise<Rpc> createClient(
      Map<String, String> config,
      final NioEventLoopGroup eloop,
      String host,
      int port,
      final String clientId,
      final String secret,
      final RpcDispatcher dispatcher); void addListener(Listener l); Future<Void> call(Object msg); Future<T> call(Object msg, Class<T> retType); Promise<T> createPromise(); @Override void close();  }