revert codec changes, it broke

This commit is contained in:
creeper123123321 2021-02-06 20:18:49 -03:00
parent 764f849d79
commit a2e90f79d0

View File

@ -201,17 +201,31 @@ class FrameCodec : ByteToMessageCodec<ByteBuf>() {
class CloudViaCodec(val info: UserConnection) : MessageToMessageCodec<ByteBuf, ByteBuf>() {
override fun decode(ctx: ChannelHandlerContext, bytebuf: ByteBuf, out: MutableList<Any>) {
if (!info.checkIncomingPacket()) throw CancelDecoderException.generate(null)
if (info.shouldTransformPacket()) {
info.transformIncoming(bytebuf, CancelDecoderException::generate)
if (!info.shouldTransformPacket()) {
out.add(bytebuf.retain())
return
}
val transformedBuf: ByteBuf = ctx.alloc().buffer().writeBytes(bytebuf)
try {
info.transformIncoming(transformedBuf, CancelDecoderException::generate)
out.add(transformedBuf.retain())
} finally {
transformedBuf.release()
}
out.add(bytebuf.retain())
}
override fun encode(ctx: ChannelHandlerContext, bytebuf: ByteBuf, out: MutableList<Any>) {
if (!info.checkOutgoingPacket()) throw CancelEncoderException.generate(null)
if (info.shouldTransformPacket()) {
info.transformOutgoing(bytebuf, CancelEncoderException::generate)
if (!info.shouldTransformPacket()) {
out.add(bytebuf.retain())
return
}
val transformedBuf: ByteBuf = ctx.alloc().buffer().writeBytes(bytebuf)
try {
info.transformOutgoing(transformedBuf, CancelEncoderException::generate)
out.add(transformedBuf.retain())
} finally {
transformedBuf.release()
}
out.add(bytebuf.retain())
}
}