62,614
社区成员
发帖
与我相关
我的任务
分享
public class BlmProtocolDecoder extends ProtocolDecoderAdapter {
@Override
public void decode(IoSession ioSession, IoBuffer ioBuffer, ProtocolDecoderOutput protocolDecoderOutput) throws Exception {
if (ioBuffer == null || protocolDecoderOutput == null) {
return;
}
System.out.println("iobuffer length:"+ioBuffer.limit());
byte[] buff = new byte[ioBuffer.limit()];
ioBuffer.get(buff);
String temp = new String(buff, CommConstants.UTF8_CHARSET_NAME);
System.out.println(">>>>>>>>> " + temp);//在这接收到的字符串有时会乱
if (temp.length() > 0) {
String json = Encoder.decode(temp);
PackageContent o = JsonHelper.deserialize(json);
protocolDecoderOutput.write(o);
}
}
}