This commit is contained in:
creeper123123321 2018-12-22 18:07:58 -02:00
parent caf6ab22ce
commit 8735230d86
No known key found for this signature in database
GPG Key ID: 0AC57D54786721D1
3 changed files with 21 additions and 22 deletions

View File

@ -94,13 +94,14 @@ public class VRDecodeHandler extends ByteToMessageDecoder {
@Override @Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
if (PipelineUtil.containsCause(cause, CancelException.class)) return; if (PipelineUtil.containsCause(cause, CancelException.class)) {
if (user.isActive()) { if (user.isActive()) {
Iterator<Runnable> iterator = user.getPostProcessingTasks().iterator(); Runnable runnable;
while (iterator.hasNext()) { while ((runnable = user.getPostProcessingTasks().poll()) != null) {
iterator.next().run(); runnable.run();
iterator.remove(); }
} }
return;
} }
super.exceptionCaught(ctx, cause); super.exceptionCaught(ctx, cause);
} }
@ -109,13 +110,11 @@ public class VRDecodeHandler extends ByteToMessageDecoder {
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
super.channelRead(ctx, msg); super.channelRead(ctx, msg);
if (user.isActive()) { if (user.isActive()) {
Iterator<Runnable> iterator = user.getPostProcessingTasks().iterator(); Runnable runnable;
while (iterator.hasNext()) { while ((runnable = user.getPostProcessingTasks().poll()) != null) {
iterator.next().run(); runnable.run();
iterator.remove();
} }
} }
// todo implement to other platforms
} }
@Override @Override

View File

@ -104,13 +104,14 @@ public class VREncodeHandler extends MessageToByteEncoder {
@Override @Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
if (PipelineUtil.containsCause(cause, CancelException.class)) return; if (PipelineUtil.containsCause(cause, CancelException.class)) {
if (user.isActive()) { if (user.isActive()) {
Iterator<Runnable> iterator = user.getPostProcessingTasks().iterator(); Runnable runnable;
while (iterator.hasNext()) { while ((runnable = user.getPostProcessingTasks().poll()) != null) {
iterator.next().run(); runnable.run();
iterator.remove(); }
} }
return;
} }
super.exceptionCaught(ctx, cause); super.exceptionCaught(ctx, cause);
} }
@ -119,10 +120,9 @@ public class VREncodeHandler extends MessageToByteEncoder {
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
super.write(ctx, msg, promise); super.write(ctx, msg, promise);
if (user.isActive()) { if (user.isActive()) {
Iterator<Runnable> iterator = user.getPostProcessingTasks().iterator(); Runnable runnable;
while (iterator.hasNext()) { while ((runnable = user.getPostProcessingTasks().poll()) != null) {
iterator.next().run(); runnable.run();
iterator.remove();
} }
} }
} }

View File

@ -88,7 +88,7 @@ public class VRUserConnection extends UserConnection {
@Override @Override
public void sendRawPacketAfterProcessing(ByteBuf packet) { public void sendRawPacketAfterProcessing(ByteBuf packet) {
ByteBuf copy = packet.alloc().buffer(); ByteBuf copy = Unpooled.buffer();
try { try {
Type.VAR_INT.write(copy, PacketWrapper.PASSTHROUGH_ID); Type.VAR_INT.write(copy, PacketWrapper.PASSTHROUGH_ID);
} catch (Exception e) { } catch (Exception e) {