use of com.generallycloud.baseio.codec.protobase.future.ParamedProtobaseFutureImpl in project baseio by generallycloud.
the class FixedSession method request.
public ParamedProtobaseFuture request(String serviceName, String content, byte[] binary) throws IOException {
ParamedProtobaseFuture future = new ParamedProtobaseFutureImpl(context, serviceName);
if (!StringUtil.isNullOrBlank(content)) {
future.write(content);
}
if (binary != null) {
future.writeBinary(binary);
}
WaiterOnFuture onReadFuture = new WaiterOnFuture();
waiterListen(serviceName, onReadFuture);
session.flush(future);
// FIXME 连接丢失时叫醒我
if (onReadFuture.await(timeout)) {
CloseUtil.close(session);
throw new TimeoutException("timeout");
}
return (ParamedProtobaseFuture) onReadFuture.getReadFuture();
}
use of com.generallycloud.baseio.codec.protobase.future.ParamedProtobaseFutureImpl in project baseio by generallycloud.
the class ParamedProtobaseProtocolDecoder method decode.
@Override
public ChannelFuture decode(SocketChannel channel, ByteBuf buffer) throws IOException {
ByteBufAllocator allocator = channel.getByteBufAllocator();
ByteBuf buf = allocator.allocate(2);
return new ParamedProtobaseFutureImpl(channel, buf);
}
use of com.generallycloud.baseio.codec.protobase.future.ParamedProtobaseFutureImpl in project baseio by generallycloud.
the class FixedSession method write.
public void write(String serviceName, String content, byte[] binary) throws IOException {
ParamedProtobaseFuture future = new ParamedProtobaseFutureImpl(context, serviceName);
if (!StringUtil.isNullOrBlank(content)) {
future.write(content);
}
if (binary != null) {
future.writeBinary(binary);
}
session.flush(future);
}
Aggregations