use of io.vertx.up.atom.Envelop in project vertx-zero by silentbalanceyh.
the class AsyncInvoker method next.
@Override
@SuppressWarnings("unchecked")
public void next(final Object proxy, final Method method, final Message<Envelop> message, final Vertx vertx) {
final Envelop envelop = message.body();
// Get type of parameter first element
final Class<?> argType = method.getParameterTypes()[Values.IDX];
// Deserialization from message bus.
final Class<?> returnType = method.getReturnType();
LOGGER.info(Info.MSG_FUTURE, this.getClass(), returnType, true);
// Get T
final Class<?> tCls = returnType.getComponentType();
if (Envelop.class == tCls) {
// Input type is Envelop, input directly
final Future<Envelop> result = Instance.invoke(proxy, method.getName(), envelop);
result.compose(item -> TunnelClient.create(this.getClass()).connect(vertx).connect(method).send(item)).setHandler(Ux.toHandler(message));
} else {
final Object reference = envelop.data();
final Object arguments = Ut.deserialize(Ut.toString(reference), argType);
final Future future = Instance.invoke(proxy, method.getName(), arguments);
future.compose(item -> TunnelClient.create(this.getClass()).connect(vertx).connect(method).send(Ux.to(item))).compose(item -> Future.succeededFuture(Ux.to(item))).setHandler(Ux.toHandler(message));
}
}
use of io.vertx.up.atom.Envelop in project vertx-zero by silentbalanceyh.
the class FutureInvoker method invoke.
@Override
@SuppressWarnings("unchecked")
public void invoke(final Object proxy, final Method method, final Message<Envelop> message) {
// Invoke directly
final Envelop envelop = message.body();
// Future<T>
final Class<?> returnType = method.getReturnType();
// Get T
final Class<?> tCls = returnType.getComponentType();
LOGGER.info(Info.MSG_FUTURE, this.getClass(), returnType, false);
if (Envelop.class == tCls) {
final Future<Envelop> result = Instance.invoke(proxy, method.getName(), envelop);
result.setHandler(item -> message.reply(item.result()));
} else {
final Future tResult = Instance.invoke(proxy, method.getName(), envelop);
tResult.setHandler(Ux.toHandler(message));
}
}
use of io.vertx.up.atom.Envelop in project vertx-zero by silentbalanceyh.
the class SyncInvoker method invoke.
@Override
public void invoke(final Object proxy, final Method method, final Message<Envelop> message) {
// Invoke directly
final Envelop envelop = message.body();
LOGGER.info(Info.MSG_FUTURE, this.getClass(), method.getReturnType(), false);
message.reply(Instance.invoke(proxy, method.getName(), envelop));
}
use of io.vertx.up.atom.Envelop in project vertx-zero by silentbalanceyh.
the class SyncInvoker method next.
@Override
public void next(final Object proxy, final Method method, final Message<Envelop> message, final Vertx vertx) {
final Envelop envelop = message.body();
LOGGER.info(Info.MSG_FUTURE, this.getClass(), method.getReturnType(), true);
final Envelop result = Instance.invoke(proxy, method.getName(), envelop);
TunnelClient.create(this.getClass()).connect(vertx).connect(method).send(result).compose(item -> Future.succeededFuture(Ux.to(item))).setHandler(Ux.toHandler(message));
}
use of io.vertx.up.atom.Envelop 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;
}
Aggregations