Adding Fidelius manual.
[iotcloud.git] / version1 / src / js / iotjs / orig / rejectedmessage.js
1 class RejectedMessage extends Entry {
2     constructor(slot, _machineid, _oldseqnum, _newseqnum, _equalto) {
3         super(slot);
4         this.machineid = _machineid;
5         this.oldseqnum = _oldseqnum;
6         this.newseqnum = _newseqnum;
7         this.equalto = _equalto;
8         this.watchset = new Set();
9     }
10     getOldSeqNum() {
11         return this.oldseqnum;
12     }
13     getNewSeqNum() {
14         return this.newseqnum;
15     }
16     getEqual() {
17         return this.equalto;
18     }
19     getMachineID() {
20         return this.machineid;
21     }
22     static decode(slot, bb) {
23         this.machineid = bb.readByte();
24         this.oldseqnum = bb.readInt64();
25         this.newseqnum = bb.readInt64();
26         this.equalto = bb.readbyte();
27         return new RejectedMessage(this.slot, this.machineid, this.oldseqnum, this.newseqnum, this.equalto === 1)
28     }
29     setWatchSet(_watchset) {
30         this.watchset = _watchset;
31     }
32     removeWatcher(_machineid) {
33         if (this.watchset.remove(_machineid)) {
34             if (this.watchset.isEmpty()) {
35                 this.setDead();
36             }
37         }
38     }
39     encode(bb) {
40         bb.writeByte(Entry.TypeRejectedMessage);
41         bb.writeInt64(this.machineid);
42         bb.writeInt64(this.oldseqnum);
43         bb.writeInt64(this.newseqnum);
44         if (this.equalto === true) {
45             bb.writebyte(1);
46         } else {
47             bb.writebyte(0);
48         }
49     }
50     getSize() {
51         return 3 * 8 + 2 * 1;
52     }
53     getType(){
54         return Entry.TypeRejectedMessage;
55     }
56     getCopy(s){
57         return new RejectedMessage(s,this.machineid,this.oldseqnum,this.newseqnum,this.equalto);
58     }
59 }