protected Object decode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
if (!(msg instanceof SctpFrame)) {
return msg;
}
final SctpChannel sctpChannel = (SctpChannel) channel;
final SctpFrame sctpFrame = (SctpFrame) msg;
if (inboundStreamFilter.filter(sctpChannel, sctpFrame)) {
final boolean complete = sctpFrame.getMessageInfo().isComplete();
if (complete) {
if (cumulation == null) {
return sctpFrame.getPayloadBuffer();
} else {
final ChannelBuffer extractedFrame = ChannelBuffers.wrappedBuffer(cumulation, sctpFrame.getPayloadBuffer());
cumulation = null;
return extractedFrame;
}
} else {
if (cumulation == null) {
cumulation = sctpFrame.getPayloadBuffer();
} else {
cumulation = ChannelBuffers.wrappedBuffer(cumulation, sctpFrame.getPayloadBuffer());
}
return null;
}
} else {
return msg;