public IoBuffer encode(Object message, Session session) {
final IoBuffer msgBuffer = (IoBuffer) message;
if (msgBuffer == null) {
return null;
}
if (msgBuffer.remaining() == 0) {
return EMPTY_BUFFER;
}
byte[] bytes = new byte[msgBuffer.remaining()];
msgBuffer.get(bytes);
IoBuffer result = IoBuffer.allocate(bytes.length,