3

As shown below I can read the byte[] sent from an IoSession without having a protocol decoder.

IoBuffer in = (IoBuffer) message;
byte[] inBytes = in.array();
int length = inBytes[0];
inBytes = Arrays.copyOfRange(inBytes, 1, length + 1);
ByteString incomingMessage = ByteString.copyFrom(inBytes);

But when I try to do:

someIoSession.write(incomingMessage.toByteArray());

I get the following error.

Don't know how to handle message of type XXXX. Are you missing a protocol encoder?

How can I just write the bytes into an IoSession?

Jared Lovin
  • 543
  • 9
  • 24
dinesh707
  • 12,106
  • 22
  • 84
  • 134

1 Answers1

1
someIoSession.write(IoBuffer.wrap(incomingMessage.toByteArray()));
eirirlar
  • 814
  • 6
  • 24
  • 1
    Although this code might solve the problem, one should always add an explanation to it. – BDL Jan 09 '17 at 23:03