remove AsynchronousByteListenChannel

This commit is contained in:
Vaci Koblizek 2022-08-09 10:42:32 +01:00 committed by Vaci
parent e3f447d4c7
commit ca7ceed32f
4 changed files with 8 additions and 28 deletions

View file

@ -31,21 +31,6 @@ public class EzRpcServer {
} }
public CompletableFuture<java.lang.Void> start() { public CompletableFuture<java.lang.Void> start() {
return this.twoPartyRpc.listen(new AsynchronousByteListenChannel() { return this.twoPartyRpc.listen(this.serverAcceptSocket);
@Override
public <A> void accept(A attachment, CompletionHandler<AsynchronousByteChannel, ? super A> handler) {
serverAcceptSocket.accept(attachment, new CompletionHandler<>() {
@Override
public void completed(AsynchronousSocketChannel result, A attachment) {
handler.completed(result, attachment);
}
@Override
public void failed(Throwable exc, A attachment) {
handler.failed(exc, attachment);
}
});
}
});
} }
} }

View file

@ -39,11 +39,11 @@ public class TwoPartyServer {
}); });
} }
public CompletableFuture<java.lang.Void> listen(AsynchronousByteListenChannel listener) { public CompletableFuture<java.lang.Void> listen(AsynchronousServerSocketChannel listener) {
var result = new CompletableFuture<AsynchronousByteChannel>(); var result = new CompletableFuture<AsynchronousSocketChannel>();
listener.accept(null, new CompletionHandler<>() { listener.accept(null, new CompletionHandler<>() {
@Override @Override
public void completed(AsynchronousByteChannel channel, Object attachment) { public void completed(AsynchronousSocketChannel channel, Object attachment) {
accept(channel); accept(channel);
result.complete(null); result.complete(null);
} }

View file

@ -2,6 +2,7 @@ package org.capnproto;
import java.io.FileDescriptor; import java.io.FileDescriptor;
import java.nio.channels.AsynchronousByteChannel; import java.nio.channels.AsynchronousByteChannel;
import java.nio.channels.AsynchronousSocketChannel;
import java.util.List; import java.util.List;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -71,7 +72,9 @@ public class TwoPartyVatNetwork
var result = this.previousWrite.whenComplete((void_, exc) -> { var result = this.previousWrite.whenComplete((void_, exc) -> {
try { try {
this.channel.shutdownOutput(); if (this.channel instanceof AsynchronousSocketChannel) {
((AsynchronousSocketChannel)this.channel).shutdownOutput();
}
} }
catch (Exception ignored) { catch (Exception ignored) {
} }

View file

@ -1,8 +0,0 @@
package org.capnproto;
import java.nio.channels.AsynchronousByteChannel;
import java.nio.channels.CompletionHandler;
public interface AsynchronousByteListenChannel {
public abstract <A> void accept(A attachment, CompletionHandler<AsynchronousByteChannel,? super A> handler);
}