From ecef3df4890be54c1da2a8a4fc1c8c1f50f1c263 Mon Sep 17 00:00:00 2001 From: zhubaomin <zhubaomin> Date: 星期一, 07 四月 2025 15:41:47 +0800 Subject: [PATCH] 式样代码管理 --- pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/LocalDecoder.java | 37 +++++++++++++++++++++++++++++++++++++ 1 files changed, 37 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/LocalDecoder.java b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/LocalDecoder.java new file mode 100644 index 0000000..976f340 --- /dev/null +++ b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/LocalDecoder.java @@ -0,0 +1,37 @@ +package com.dy.testClient.tcpClient; + +import com.dy.common.util.ByteUtil; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.mina.core.buffer.IoBuffer; +import org.apache.mina.core.session.IoSession; +import org.apache.mina.filter.codec.CumulativeProtocolDecoder; +import org.apache.mina.filter.codec.ProtocolDecoderOutput; + +import java.io.IOException; + +public class LocalDecoder extends CumulativeProtocolDecoder { + + private static final Logger log = LogManager.getLogger(LocalDecoder.class) ; + + private static final String DECODER_STATE_KEY = LocalDecoder.class.getName() + ".STATE"; + + public static final int MAX_SIZE = 2147483647 ; + + + /** + * 瀵圭綉缁滀紶杈撴潵鐨勬暟鎹繘琛岃В鐮� + */ + protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws IOException, Exception{ + int remain = in.remaining() ; + if(remain > 0){ + byte[] preByte = new byte[remain]; + in.get(preByte) ; + in.position(0) ; + log.info("鏀跺埌涓績涓嬭鏁版嵁锛�" + ByteUtil.bytes2Hex(preByte, true)); + } + return true; + } + + +} -- Gitblit v1.8.0