From b4f69a6e8e0669ac2d55369ccbc0ccc836059610 Mon Sep 17 00:00:00 2001 From: creeper123123321 Date: Tue, 8 Jan 2019 06:51:57 -0200 Subject: [PATCH] use packetwrapper#send refactor --- .../viafabric/handler/VRDecodeHandler.java | 10 ++++++++-- .../viafabric/handler/VREncodeHandler.java | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/github/creeper123123321/viafabric/handler/VRDecodeHandler.java b/src/main/java/com/github/creeper123123321/viafabric/handler/VRDecodeHandler.java index e531c89..f7548ed 100644 --- a/src/main/java/com/github/creeper123123321/viafabric/handler/VRDecodeHandler.java +++ b/src/main/java/com/github/creeper123123321/viafabric/handler/VRDecodeHandler.java @@ -94,11 +94,17 @@ public class VRDecodeHandler extends ByteToMessageDecoder { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { - if (PipelineUtil.containsCause(cause, CancelException.class)) - return; + if (PipelineUtil.containsCause(cause, CancelException.class)) return; super.exceptionCaught(ctx, cause); } + @Override + public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { + try (AutoCloseable ignored = user.createTaskListAndRunOnClose()) { + super.channelRead(ctx, msg); + } + } + @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { ProtocolInfo info = user.get(ProtocolInfo.class); diff --git a/src/main/java/com/github/creeper123123321/viafabric/handler/VREncodeHandler.java b/src/main/java/com/github/creeper123123321/viafabric/handler/VREncodeHandler.java index f1533ff..34284b8 100644 --- a/src/main/java/com/github/creeper123123321/viafabric/handler/VREncodeHandler.java +++ b/src/main/java/com/github/creeper123123321/viafabric/handler/VREncodeHandler.java @@ -104,8 +104,14 @@ public class VREncodeHandler extends MessageToByteEncoder { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { - if (PipelineUtil.containsCause(cause, CancelException.class)) - return; + if (PipelineUtil.containsCause(cause, CancelException.class)) return; super.exceptionCaught(ctx, cause); } + + @Override + public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { + try (AutoCloseable ignored = user.createTaskListAndRunOnClose()) { + super.write(ctx, msg, promise); + } + } }