Skip to content

Commit

Permalink
sdk/js: revert back to using listenerCount() and emit for handling re…
Browse files Browse the repository at this point in the history
…quests
  • Loading branch information
lithdew committed Jun 11, 2020
1 parent fcbd554 commit 553aa0b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions ts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,7 @@ class Client {
const seq = frame.readUInt32BE();
frame = frame.slice(4);

const listeners = this.pending.listeners(`${seq}`);

if (seq === 0 || listeners.length === 0) {
if (seq === 0 || this.pending.listenerCount(`${seq}`) === 0) {
const opcode = frame.readUInt8();
frame = frame.slice(1);

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

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

0 comments on commit 553aa0b

Please sign in to comment.