| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.common.mw.protocol; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import org.apache.mina.core.buffer.IoBuffer; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dy.common.mw.channel.tcp.PrefixedDataAvailableStatus; | 
|---|
|  |  |  | import org.apache.mina.core.session.IoSession; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public interface PrefixedDataAvailable { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 分析上线数据(网络连接后第一包数据)是否可获得 | 
|---|
|  |  |  | * @param in IoBuffer | 
|---|
|  |  |  | * @param remain 一定时大于0的数据 | 
|---|
|  |  |  | * @param minDataLength 最小数据长度 | 
|---|
|  |  |  | * @param maxDataLength 最大数据长度,达到或超过此长度,认为是垃圾数据。例如:数据头部是正确的,但合法数据结尾总不出现,认为此数据垃圾数据 | 
|---|
|  |  |  | * @return 不时本协议数据时返回空 | 
|---|
|  |  |  | * @throws Exception 异常 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | PrefixedDataAvailableStatus forOnLine(IoSession ioSession, | 
|---|
|  |  |  | IoBuffer in, | 
|---|
|  |  |  | int remain, | 
|---|
|  |  |  | int minDataLength, | 
|---|
|  |  |  | int maxDataLength) throws Exception ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 分析上线后(网络连接后非第一包数据)是否可获得 | 
|---|
|  |  |  | * @param in IoBuffer | 
|---|
|  |  |  | * @param remain 一定时大于0的数据 | 
|---|
|  |  |  | * @param minDataLength 最小数据长度 | 
|---|
|  |  |  | * @param maxDataLength 最大数据长度,达到或超过此长度,认为是垃圾数据。例如:数据头部是正确的,但合法数据结尾总不出现,认为此数据垃圾数据 | 
|---|
|  |  |  | * @return PrefixedDataAvailableStatus | 
|---|
|  |  |  | * @throws Exception 异常 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | PrefixedDataAvailableStatus forUpData(IoSession ioSession, | 
|---|
|  |  |  | IoBuffer in, | 
|---|
|  |  |  | int remain, | 
|---|
|  |  |  | int minDataLength, | 
|---|
|  |  |  | int maxDataLength) throws Exception; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|