Skip to content

Commit 0a9762c

Browse files
refactor: use Namespace#sockets to broadcast
1 parent 5d81b13 commit 0a9762c

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export class Adapter extends EventEmitter {
122122

123123
for (const id of this.rooms.get(room)) {
124124
if (ids.has(id) || except.has(id)) continue;
125-
const socket = this.nsp.connected.get(id);
125+
const socket = this.nsp.sockets.get(id);
126126
if (socket) {
127127
socket.packet(encodedPackets, packetOpts);
128128
ids.add(id);
@@ -132,7 +132,7 @@ export class Adapter extends EventEmitter {
132132
} else {
133133
for (const [id] of this.sids) {
134134
if (except.has(id)) continue;
135-
const socket = this.nsp.connected.get(id);
135+
const socket = this.nsp.sockets.get(id);
136136
if (socket) socket.packet(encodedPackets, packetOpts);
137137
}
138138
}
@@ -151,14 +151,14 @@ export class Adapter extends EventEmitter {
151151
if (!this.rooms.has(room)) continue;
152152

153153
for (const id of this.rooms.get(room)) {
154-
if (this.nsp.connected.has(id)) {
154+
if (this.nsp.sockets.has(id)) {
155155
sids.add(id);
156156
}
157157
}
158158
}
159159
} else {
160160
for (const [id] of this.sids) {
161-
if (this.nsp.connected.has(id)) sids.add(id);
161+
if (this.nsp.sockets.has(id)) sids.add(id);
162162
}
163163
}
164164

test/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe("socket.io-adapter", () => {
2929
it("should return a list of sockets", async () => {
3030
const adapter = new Adapter({
3131
server: { encoder: null },
32-
connected: new Map([
32+
sockets: new Map([
3333
["s1", true],
3434
["s2", true],
3535
["s3", true]

0 commit comments

Comments
 (0)