use of io.vertx.up.exception._501RpcMethodMissingException in project vertx-zero by silentbalanceyh.
the class UnityTunnel method init.
@Override
public BindableService init(final Vertx vertx) {
return new UnityServiceGrpc.UnityServiceVertxImplBase() {
@Override
public void unityCall(final IpcRequest request, final Future<IpcResponse> future) {
// IpcData building
final IpcData data = DataEncap.consume(request, IpcType.UNITY);
// Method called with message handler
final Envelop envelop = DataEncap.consume(data);
// Method handle
final Method method = IPCS.get(data.getAddress());
// Work mode
if (null == method) {
// No Rpc Handler here
final Envelop community = Envelop.failure(new _501RpcMethodMissingException(this.getClass(), data.getAddress()));
// Build IpcData
final IpcData responseData = UnityTunnel.this.build(community, envelop);
future.complete(DataEncap.out(responseData));
} else {
// Execute Transit
final Transit transit = UnityTunnel.this.getTransit(method, vertx);
// Execute Transit
final Future<Envelop> result = transit.async(envelop);
result.setHandler(res -> {
final IpcData responseData = UnityTunnel.this.build(res.result(), envelop);
future.complete(DataEncap.out(responseData));
});
}
}
};
}
Aggregations