okleine / nCoAP

Java implementation of the CoAP protocol using netty
BSD 3-Clause "New" or "Revised" License
179 stars 57 forks source link

Incorrect console output in SimpleCoapClientApplication #6

Closed stefanhueske closed 12 years ago

stefanhueske commented 12 years ago

SimpleCoapClientApplication.receiveCoapResponse() does not print out the payload but the ChannelBuffers backing byte array. If there is no easier way you could use the function I implemented in my fork.

from class ByteTestTools:

public static byte[] getByteArrayFromChannelBuffer(ChannelBuffer channelBuffer) {
        byte[] convertedByteArray = new byte[channelBuffer.readableBytes()];
        for (int i = 0; channelBuffer.readable(); i++) {
              convertedByteArray[i] = channelBuffer.readByte();
        }        
        return convertedByteArray;
}

(note: I fixed this issue in my fork 78fb78cf292816ff48e4da1483ad5c0409e62d74)