DataInputStream dis = new DataInputStream(stream);
return unmarshal(dis);
}
public void marshal(Object command, DataOutput dataOut) throws IOException {
MQTTFrame frame = (MQTTFrame) command;
dataOut.write(frame.header());
int remaining = 0;
for (Buffer buffer : frame.buffers) {
remaining += buffer.length;
}