diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/proxy/src/main/java/ac/eva/hyproxy/io/HytaleConnection.java b/proxy/src/main/java/ac/eva/hyproxy/io/HytaleConnection.java index caf0b78..1d16b3a 100644 --- a/proxy/src/main/java/ac/eva/hyproxy/io/HytaleConnection.java +++ b/proxy/src/main/java/ac/eva/hyproxy/io/HytaleConnection.java @@ -82,6 +82,35 @@ public void channelInactive(ChannelHandlerContext ctx) { } } + @Override + public void channelWritabilityChanged(ChannelHandlerContext ctx) { + QuicStreamChannel streamChannel = (QuicStreamChannel) ctx.channel(); + NetworkChannel networkChannel = this.channelsByStreamId.getOrDefault(streamChannel.streamId(), NetworkChannel.DEFAULT); + + QuicStreamChannel peerStream = this.getPeerStream(networkChannel); + if (peerStream != null && peerStream.isActive()) { + peerStream.config().setAutoRead(streamChannel.isWritable()); + } + + ctx.fireChannelWritabilityChanged(); + } + + private @Nullable QuicStreamChannel getPeerStream(NetworkChannel networkChannel) { + if (this.player == null) { + return null; + } + + HytaleConnection peer = this.player.getInboundConnection() == this + ? this.player.getOutboundConnection() + : this.player.getInboundConnection(); + + if (peer == null) { + return null; + } + + return peer.streams.get(networkChannel); + } + public String getIdentifier() { if (this.hasPlayer()) { return player.getIdentifier();