Cleaned up git
[iotcloud.git] / version1 / src / js / iotjs / orig / rejectedmessage.js
diff --git a/version1/src/js/iotjs/orig/rejectedmessage.js b/version1/src/js/iotjs/orig/rejectedmessage.js
new file mode 100644 (file)
index 0000000..f9f775a
--- /dev/null
@@ -0,0 +1,59 @@
+class RejectedMessage extends Entry {
+    constructor(slot, _machineid, _oldseqnum, _newseqnum, _equalto) {
+        super(slot);
+        this.machineid = _machineid;
+        this.oldseqnum = _oldseqnum;
+        this.newseqnum = _newseqnum;
+        this.equalto = _equalto;
+        this.watchset = new Set();
+    }
+    getOldSeqNum() {
+        return this.oldseqnum;
+    }
+    getNewSeqNum() {
+        return this.newseqnum;
+    }
+    getEqual() {
+        return this.equalto;
+    }
+    getMachineID() {
+        return this.machineid;
+    }
+    static decode(slot, bb) {
+        this.machineid = bb.readByte();
+        this.oldseqnum = bb.readInt64();
+        this.newseqnum = bb.readInt64();
+        this.equalto = bb.readbyte();
+        return new RejectedMessage(this.slot, this.machineid, this.oldseqnum, this.newseqnum, this.equalto === 1)
+    }
+    setWatchSet(_watchset) {
+        this.watchset = _watchset;
+    }
+    removeWatcher(_machineid) {
+        if (this.watchset.remove(_machineid)) {
+            if (this.watchset.isEmpty()) {
+                this.setDead();
+            }
+        }
+    }
+    encode(bb) {
+        bb.writeByte(Entry.TypeRejectedMessage);
+        bb.writeInt64(this.machineid);
+        bb.writeInt64(this.oldseqnum);
+        bb.writeInt64(this.newseqnum);
+        if (this.equalto === true) {
+            bb.writebyte(1);
+        } else {
+            bb.writebyte(0);
+        }
+    }
+    getSize() {
+        return 3 * 8 + 2 * 1;
+    }
+    getType(){
+       return Entry.TypeRejectedMessage;
+    }
+    getCopy(s){
+       return new RejectedMessage(s,this.machineid,this.oldseqnum,this.newseqnum,this.equalto);
+    }
+}