package iotcloud; import java.nio.ByteBuffer; /** * This Entry records the last message sent by a given machine. * @author Brian Demsky * @version 1.0 */ class LastMessage extends Entry { private long machineid; private long seqnum; public LastMessage(Slot slot, long _machineid, long _seqnum) { super(slot); machineid=_machineid; seqnum=_seqnum; } public long getMachineID() { return machineid; } public long getSequenceNumber() { return seqnum; } static Entry decode(Slot slot, ByteBuffer bb) { long machineid=bb.getLong(); long seqnum=bb.getLong(); return new LastMessage(slot, machineid, seqnum); } public void encode(ByteBuffer bb) { bb.put(Entry.TypeLastMessage); bb.putLong(machineid); bb.putLong(seqnum); } public int getSize() { return 2*Long.BYTES+Byte.BYTES; } public byte getType() { return Entry.TypeLastMessage; } public Entry getCopy(Slot s) { return new LastMessage(s, machineid, seqnum); } }