xP: fix command sequence number generation

This commit is contained in:
Přemysl Eric Janouch 2022-09-10 16:42:49 +02:00
parent 9eaf78f823
commit c06894b291
Signed by: p
GPG Key ID: A0420B94F92B9493

View File

@ -110,8 +110,9 @@ class RelayRpc extends EventTarget {
if (typeof params !== 'object') if (typeof params !== 'object')
throw "Method parameters must be an object" throw "Method parameters must be an object"
// Left shifts in Javascript convert to a 32-bit signed number.
let seq = ++this.commandSeq let seq = ++this.commandSeq
if (seq >= 1 << 32) if ((seq << 0) != seq)
seq = this.commandSeq = 0 seq = this.commandSeq = 0
this.ws.send(JSON.stringify({commandSeq: seq, data: params})) this.ws.send(JSON.stringify({commandSeq: seq, data: params}))