use of org.webpieces.nio.api.channels.Channel in project webpieces by deanhiller.
the class IntegTestClientNotRead method write.
private void write(Channel channel, String reason, final int counter) {
log.info("write from client. reason=" + reason);
byte[] data = new byte[2000];
ByteBuffer buffer = ByteBuffer.wrap(data);
CompletableFuture<Channel> write = channel.write(buffer);
final int count = counter + 1;
if (counter >= 100) {
write.thenAccept(p -> write(channel, "wrote data from client", count)).whenComplete((r, e) -> finished(r, e));
} else {
write.thenAcceptAsync(p -> write(channel, "wrote data async", 0), executor).whenComplete((r, e) -> finished(r, e));
}
}
Aggregations