Skip to content

Commit

Permalink
fix: Adapter#encode() is now synchronous
Browse files Browse the repository at this point in the history
  • Loading branch information
darrachequesne committed Sep 28, 2020
1 parent 7216d7a commit c043650
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,28 +114,28 @@ export class Adapter extends EventEmitter {
const ids = new Set();

packet.nsp = this.nsp.name;
this.encoder.encode(packet, encodedPackets => {
if (rooms.size) {
for (const room of rooms) {
if (!this.rooms.has(room)) continue;

for (const id of this.rooms.get(room)) {
if (ids.has(id) || except.has(id)) continue;
const socket = this.nsp.connected.get(id);
if (socket) {
socket.packet(encodedPackets, packetOpts);
ids.add(id);
}
}
}
} else {
for (const [id] of this.sids) {
if (except.has(id)) continue;
const encodedPackets = this.encoder.encode(packet);

if (rooms.size) {
for (const room of rooms) {
if (!this.rooms.has(room)) continue;

for (const id of this.rooms.get(room)) {
if (ids.has(id) || except.has(id)) continue;
const socket = this.nsp.connected.get(id);
if (socket) socket.packet(encodedPackets, packetOpts);
if (socket) {
socket.packet(encodedPackets, packetOpts);
ids.add(id);
}
}
}
});
} else {
for (const [id] of this.sids) {
if (except.has(id)) continue;
const socket = this.nsp.connected.get(id);
if (socket) socket.packet(encodedPackets, packetOpts);
}
}
}

/**
Expand Down

0 comments on commit c043650

Please sign in to comment.