pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/PrefixedDataAvailableV1.java
@@ -8,11 +8,13 @@
import org.apache.logging.log4j.Logger;
import org.apache.mina.core.buffer.BufferDataException;
import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.core.session.IoSession;
@AnnotationPrefixedDataAvailable(
      enable = true,
      protocolName = ProtocolConstantV206V1.protocolName,
      protocolVersion = ProtocolConstantV206V1.protocolVer,
      priority = ProtocolConstantV206V1.priority,
      onLineDataMinLength = ProtocolConstantV206V1.onLineDataMinLength,
      headMinLength = ProtocolConstantV206V1.headMinLength)
@@ -22,7 +24,7 @@
   private static final Logger log = LogManager.getLogger(PrefixedDataAvailableV1.class) ;
   
   private static final String protocolName = ProtocolConstantV206V1.protocolName ;
   private static final short protocolVersion = ProtocolConstantV206V1.protocolVer ;
   /**
    * 分析上线数据(网络连接后第一包数据)是否可获得
@@ -33,11 +35,12 @@
    * @return 不是本协议数据时返回空
    * @throws Exception 异常
    */
   public PrefixedDataAvailableStatus forOnLine(IoBuffer in,
         int remain,
         int minDataLength,
         int maxDataLength
         ) throws Exception {
   public PrefixedDataAvailableStatus forOnLine(IoSession ioSession,
                                     IoBuffer in,
                                     int remain,
                                     int minDataLength,
                                     int maxDataLength
                                     ) throws Exception {
      
      int oldPosition = in.position() ;
      byte[] preByte = new byte[remain];
@@ -45,7 +48,7 @@
      //in.position(0) ;//错误用法,如果发生粘包数据,将会死循环
      in.position(oldPosition) ;
      return this.doForData(preByte, minDataLength, maxDataLength) ;
      return this.doForData(ioSession, preByte, minDataLength, maxDataLength) ;
   }
   /**
@@ -58,28 +61,30 @@
    * @throws Exception 异常
    */
   @Override
   public PrefixedDataAvailableStatus forUpData(IoBuffer in,
         int remain,
         int minDataLength,
         int maxDataLength) throws Exception {
   public PrefixedDataAvailableStatus forUpData(IoSession ioSession,
                                     IoBuffer in,
                                     int remain,
                                     int minDataLength,
                                     int maxDataLength) throws Exception {
      int oldPosition = in.position() ;
      byte[] preByte = new byte[remain];
      in.get(preByte) ;
      //in.position(0) ;//错误用法,如果发生粘包数据,将会死循环
      in.position(oldPosition) ;
      
      return this.doForData(preByte, minDataLength, maxDataLength) ;
      return this.doForData(ioSession, preByte, minDataLength, maxDataLength) ;
    }
   /**
    * 进行判断
    * @param ioSession ioSession
    * @param preByte byte[]
    * @param minDataLength 最小数据长度
    * @param maxDataLength 最大数据长度
    * @return PrefixedDataAvailableStatus
    * @throws Exception 异常
    */
   private PrefixedDataAvailableStatus doForData(byte[] preByte, int minDataLength, int maxDataLength) throws Exception{
   private PrefixedDataAvailableStatus doForData(IoSession ioSession, byte[] preByte, int minDataLength, int maxDataLength) throws Exception{
      int remain = preByte.length ;
       
        if (remain < minDataLength) {
@@ -114,11 +119,11 @@
        
        if(remain == dataLen){
           //不断不粘
            return new PrefixedDataAvailableStatus().completed(dataLen) ;
            return new PrefixedDataAvailableStatus().completed(dataLen, protocolName, protocolVersion) ;
        }else if(remain > dataLen){
         String headHex = ByteUtil.bytes2Hex(preByte, true) ;
           log.warn("收到数据之帧前部:" + headHex + ",但发生粘包现象。") ;
            return new PrefixedDataAvailableStatus().adjoined(dataLen) ;
            return new PrefixedDataAvailableStatus().adjoined(dataLen, protocolName, protocolVersion) ;
        }else{
           // remain < dataLen
         String headHex = ByteUtil.bytes2Hex(preByte, true) ;