Cleaned up git
[iotcloud.git] / version1 / src / js / iotjs / orig / lastmessage.js
diff --git a/version1/src/js/iotjs/orig/lastmessage.js b/version1/src/js/iotjs/orig/lastmessage.js
new file mode 100644 (file)
index 0000000..496862f
--- /dev/null
@@ -0,0 +1,39 @@
+class LastMessage extends Entry{
+       constructor(slot,_machineid,_seqnum){
+               super(slot);
+               this.machineid = _machineid;
+               this.seqnum = _seqnum;
+       }
+       getMachineID(){
+               return this.machineid;
+       }
+       getSequenceNumber() {
+               return this.seqnum;
+       }
+       decode(slot,bb){
+               //slot and bb are instancesof Slot and ByteBuffer
+               if(!(slot instanceof Slot && bb instanceof ByteBuffer)){
+                       throw new Error('Problem with the Arguments');
+               }
+               var machineid = bb.readInt64();
+               var seqnum = bb.readInt64();
+               return new LastMessage(slot,machineid,seqnum);
+       }
+       encode(bb){
+               bb.writeByte(Entry.TypeLastMessage);
+               bb.writeInt64(this.machineid);
+               bb.writeInt64(this.seqnum);
+       }
+       getSize(){
+               return 2*(1+1);
+       }
+       getType(){
+               return Entry.TypeLastMessage;
+       }
+       getCopy(s){
+               if(!(s instanceof Slot)){
+                       throw new Error('Argument must be a slot object');
+               }
+               return new LastMessage(s,this.machineid,this.seqnum);
+       }
+}
\ No newline at end of file