use of io.vertx.tp.ipc.eon.IpcRequest in project vertx-zero by silentbalanceyh.
the class UnitySpear method send.
@Override
public Future<Envelop> send(final Vertx vertx, final IpcData data) {
// Channel
final ManagedChannel channel = RpcSslTool.getChannel(vertx, data);
final UnityServiceGrpc.UnityServiceVertxStub stub = UnityServiceGrpc.newVertxStub(channel);
// Request
final IpcRequest request = DataEncap.in(data);
// Call and return to future
final Future<Envelop> handler = Future.future();
stub.unityCall(request, response -> RpcRepdor.create(getClass()).reply(handler, response));
return handler;
}
use of io.vertx.tp.ipc.eon.IpcRequest 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));
});
}
}
};
}
use of io.vertx.tp.ipc.eon.IpcRequest in project vertx-zero by silentbalanceyh.
the class UnityStub method traffic.
@Override
public Future<JsonObject> traffic(final IpcData data) {
final UnityServiceGrpc.UnityServiceVertxStub stub = UnityServiceGrpc.newVertxStub(this.channel);
// Request
final IpcRequest request = DataEncap.in(data);
// Call and return to future
final Future<JsonObject> handler = Future.future();
stub.unityCall(request, response -> RpcRepdor.create(this.getClass()).replyJson(handler, response));
return handler;
}
Aggregations