Apache Mina CumulativeProtocolDecoder 内部函数说明

public void decode(IoSession session,
                   IoBuffer in,
                   ProtocolDecoderOutput out)
            throws Exception

Cumulates content of in into internal buffer and forwards
 decoding request to doDecode(IoSession, IoBuffer, ProtocolDecoderOutput).
 doDecode() is invoked repeatedly until it returns false
 and the cumulative buffer is compacted after decoding ends.
Throws:
IllegalStateException- if your doDecode() returned true not consumingthe cumulative buffer.
Exception - ifthe read data violated protocol specification
说明:decode函数将IoBuffer in对象中的内容累积添加到 
内部的buffer上,并调用doDecode方法。,如果doDecode方法返回false且内部累积buffer中的数据再次可用时,doDecode方法会被再次调用,直到doDecode方法返回true;



protected abstract boolean doDecode(IoSession session,
                                    IoBuffer in,
                                    ProtocolDecoderOutput out)
                             throws Exception
Implement this method to consume the specified cumulativebuffer and decode its content into message(s).
Parameters:
in - the cumulative buffer
Returns:
true if and only if there's more to decode in thebuffer and you want to have doDecode method invoked again.Return false if remaining data is not enough to decode,then this method will be invoked again when more data iscumulated.
Throws:
Exception - ifcannot decode in.
说明:如果累积buffer中的数据长度大于解析协议需要的长度时,返回true;当该方法返回结果为true时,会再次调用该方法。如果累积buffer中的数据不够协议解析需要的长度时,返回false,直到累积buffer中的数据再次可用时。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值