Skip to content

Commit

Permalink
sdk/js: resolve multiple listeners on the same sequence number
Browse files Browse the repository at this point in the history
  • Loading branch information
lithdew committed Jun 11, 2020
1 parent 80b8d9d commit fcbd554
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,9 @@ class Client {
const seq = frame.readUInt32BE();
frame = frame.slice(4);

if (seq === 0 || this.pending.listeners(`${seq}`).length === 0) {
const listeners = this.pending.listeners(`${seq}`);

if (seq === 0 || listeners.length === 0) {
const opcode = frame.readUInt8();
frame = frame.slice(1);

Expand All @@ -361,7 +363,7 @@ class Client {

this.reply(seq, packet.data);
} else {
this.pending.emit(`${seq}`, frame);
listeners.forEach(listener => listener(frame));
}
}
}
Expand Down

0 comments on commit fcbd554

Please sign in to comment.