如下所示,我可以在没有协议解码器的情况下读取从IoSession发送的byte []。
IoBuffer in = (IoBuffer) message;
byte[] inBytes = in.array();
int length = inBytes[0];
inBytes = Arrays.copyOfRange(inBytes, 1, length + 1);
ByteString incomingMessage = ByteString.copyFrom(inBytes);
但是当我尝试做的时候:
someIoSession.write(incomingMessage.toByteArray());
我收到以下错误。
Don't know how to handle message of type XXXX. Are you missing a protocol encoder?
如何将字节写入IoSession?
答案 0 :(得分:1)
someIoSession.write(IoBuffer.wrap(incomingMessage.toByteArray()));