mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
refactor: use Namespace#sockets to broadcast
This commit is contained in:
@@ -122,7 +122,7 @@ export class Adapter extends EventEmitter {
|
||||
|
||||
for (const id of this.rooms.get(room)) {
|
||||
if (ids.has(id) || except.has(id)) continue;
|
||||
const socket = this.nsp.connected.get(id);
|
||||
const socket = this.nsp.sockets.get(id);
|
||||
if (socket) {
|
||||
socket.packet(encodedPackets, packetOpts);
|
||||
ids.add(id);
|
||||
@@ -132,7 +132,7 @@ export class Adapter extends EventEmitter {
|
||||
} else {
|
||||
for (const [id] of this.sids) {
|
||||
if (except.has(id)) continue;
|
||||
const socket = this.nsp.connected.get(id);
|
||||
const socket = this.nsp.sockets.get(id);
|
||||
if (socket) socket.packet(encodedPackets, packetOpts);
|
||||
}
|
||||
}
|
||||
@@ -151,14 +151,14 @@ export class Adapter extends EventEmitter {
|
||||
if (!this.rooms.has(room)) continue;
|
||||
|
||||
for (const id of this.rooms.get(room)) {
|
||||
if (this.nsp.connected.has(id)) {
|
||||
if (this.nsp.sockets.has(id)) {
|
||||
sids.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (const [id] of this.sids) {
|
||||
if (this.nsp.connected.has(id)) sids.add(id);
|
||||
if (this.nsp.sockets.has(id)) sids.add(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ describe("socket.io-adapter", () => {
|
||||
it("should return a list of sockets", async () => {
|
||||
const adapter = new Adapter({
|
||||
server: { encoder: null },
|
||||
connected: new Map([
|
||||
sockets: new Map([
|
||||
["s1", true],
|
||||
["s2", true],
|
||||
["s3", true]
|
||||
|
||||
Reference in New Issue
Block a user