allow network to use bytechannels
This commit is contained in:
parent
c0a57d304f
commit
37aa04b262
1 changed files with 6 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
||||||
package org.capnproto;
|
package org.capnproto;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.channels.AsynchronousByteChannel;
|
||||||
import java.nio.channels.AsynchronousSocketChannel;
|
import java.nio.channels.AsynchronousSocketChannel;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
@ -20,13 +21,13 @@ public class TwoPartyVatNetwork
|
||||||
|
|
||||||
private CompletableFuture<java.lang.Void> previousWrite = CompletableFuture.completedFuture(null);
|
private CompletableFuture<java.lang.Void> previousWrite = CompletableFuture.completedFuture(null);
|
||||||
private final CompletableFuture<java.lang.Void> disconnectPromise = new CompletableFuture<>();
|
private final CompletableFuture<java.lang.Void> disconnectPromise = new CompletableFuture<>();
|
||||||
private final AsynchronousSocketChannel channel;
|
private final AsynchronousByteChannel channel;
|
||||||
private final RpcTwoPartyProtocol.Side side;
|
private final RpcTwoPartyProtocol.Side side;
|
||||||
private final MessageBuilder peerVatId = new MessageBuilder(4);
|
private final MessageBuilder peerVatId = new MessageBuilder(4);
|
||||||
private boolean accepted;
|
private boolean accepted;
|
||||||
private MessageTap tap;
|
private MessageTap tap;
|
||||||
|
|
||||||
public TwoPartyVatNetwork(AsynchronousSocketChannel channel, RpcTwoPartyProtocol.Side side) {
|
public TwoPartyVatNetwork(AsynchronousByteChannel channel, RpcTwoPartyProtocol.Side side) {
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
this.side = side;
|
this.side = side;
|
||||||
this.peerVatId.initRoot(RpcTwoPartyProtocol.VatId.factory).setSide(
|
this.peerVatId.initRoot(RpcTwoPartyProtocol.VatId.factory).setSide(
|
||||||
|
@ -114,7 +115,9 @@ public class TwoPartyVatNetwork
|
||||||
|
|
||||||
var result = this.previousWrite.thenRun(() -> {
|
var result = this.previousWrite.thenRun(() -> {
|
||||||
try {
|
try {
|
||||||
this.channel.shutdownOutput();
|
if (this.channel instanceof AsynchronousSocketChannel) {
|
||||||
|
((AsynchronousSocketChannel)this.channel).shutdownOutput();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ioExc) {
|
catch (Exception ioExc) {
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue