more code
[iotcloud.git] / src / java / iotcloud / LastMessage.java
1 package iotcloud;
2
3 import java.nio.ByteBuffer;
4
5 class LastMessage extends Entry {
6         private long machineid;
7         private long seqnum;
8         
9         LastMessage(Slot slot, long _machineid, long _seqnum) {
10                 super(slot);
11                 machineid=_machineid;
12                 seqnum=_seqnum;
13         }
14
15         long getMachineID() {
16                 return machineid;
17         }
18
19         long getSequenceNumber() {
20                 return seqnum;
21         }
22         
23         static Entry decode(Slot slot, ByteBuffer bb) {
24                 long machineid=bb.getLong();
25                 long seqnum=bb.getLong();
26                 return new LastMessage(slot, machineid, seqnum);
27         }
28
29         void encode(ByteBuffer bb) {
30                 bb.put(Entry.TypeLastMessage);
31                 bb.putLong(machineid);
32                 bb.putLong(seqnum);
33         }
34         
35         int getSize() {
36                 return 2*Long.BYTES+Byte.BYTES;
37         }
38
39         byte getType() {
40                 return Entry.TypeLastMessage;
41         }
42 }
43
44