public Message(byte[] data) { buffer = ByteBuffer.allocate(headSize() + data.length); buffer.put(VERSION); buffer.putLong(Util.getCRC32(data)); buffer.put(data); buffer.rewind(); }
public String getContent() { ByteBuffer buf = this.payload(); byte[] b = new byte[buf.remaining()]; buf.get(b); return Util.fromBytes(b); }
public boolean valid() { return checksum() == Util.getCRC32(buffer.array(), buffer.arrayOffset() + headSize(), payloadSize()); }