Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ export class RedisAdapter extends Adapter {
if (!onlyLocal) {
const rawOpts = {
rooms: [...opts.rooms],
except: [...opts.except],
except: [...new Set(opts.except)],
flags: opts.flags,
};
const msg = msgpack.encode([this.uid, packet, rawOpts]);
Expand Down
20 changes: 20 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,26 @@ let socket1, socket2, socket3;
});
});

it("uses a namespace to broadcast to rooms", () => {
socket1.join("woot");
client2.emit("do broadcast");
socket2.on("do broadcast", () => {
namespace2.to("woot").emit("broadcast");
});

client1.on("broadcast", () => {
setTimeout(done, 100);
});

client2.on("broadcast", () => {
throw new Error("Not in room");
});

client3.on("broadcast", () => {
throw new Error("Not in room");
});
});

it("broadcasts to multiple rooms at a time", (done) => {
function test() {
client2.emit("do broadcast");
Expand Down