code: private void readPayloadFromBuffer(final ByteBuffer buffer)
      throws IOException {
      int toRead = payload.length - payloadOffset;
      int available = buffer.remaining();
      toRead = Math.min(toRead, available);
      getLogger().debug("Reading %d payload bytes", toRead);
      buffer.get(payload, payloadOffset, toRead);
      payloadOffset += toRead;
  
  
      if (payloadOffset == payload.length) {
        finishedPayload(payload);
      }
    }
docs: Read the payload from the buffer.
  
  @param buffer the buffer to read from.
  @throws IOException if an error occures during payload finishing.