Skip to content

Commit 130f28a

Browse files
refactor: rename clients and clientRooms methods
In Socket.IO glossary: - a Client manages the low-level connection and can be associated with several Sockets - a Socket belongs to a given Namespace
1 parent 53ed3f4 commit 130f28a

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ class Adapter extends EventEmitter {
124124
}
125125

126126
/**
127-
* Gets a list of clients by sid.
127+
* Gets a list of sockets by sid.
128128
*
129129
* @param {Set<string>} rooms the explicit set of rooms to check.
130130
* @public
131131
*/
132-
clients(rooms) {
132+
sockets(rooms) {
133133
const sids = new Set();
134134

135135
if (rooms.size) {
@@ -152,12 +152,12 @@ class Adapter extends EventEmitter {
152152
}
153153

154154
/**
155-
* Gets the list of rooms a given client has joined.
155+
* Gets the list of rooms a given socket has joined.
156156
*
157157
* @param {String} id the socket id
158158
* @public
159159
*/
160-
clientRooms(id) {
160+
socketRooms(id) {
161161
return this.sids.get(id);
162162
}
163163
}

test/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe("socket.io-adapter", () => {
2626
expect(adapter.sids.has("s2")).to.be(false);
2727
});
2828

29-
it("should return a list of clients", () => {
29+
it("should return a list of sockets", () => {
3030
const adapter = new Adapter({
3131
server: { encoder: null },
3232
connected: new Map([
@@ -39,11 +39,11 @@ describe("socket.io-adapter", () => {
3939
adapter.addAll("s2", new Set(["r2", "r3"]));
4040
adapter.addAll("s3", new Set(["r3"]));
4141

42-
const clients = adapter.clients(new Set());
43-
expect(clients).to.be.a(Set);
44-
expect(clients.size).to.be(3);
45-
expect(adapter.clients(new Set(["r2"])).size).to.be(2);
46-
expect(adapter.clients(new Set(["r4"])).size).to.be(0);
42+
const sockets = adapter.sockets(new Set());
43+
expect(sockets).to.be.a(Set);
44+
expect(sockets.size).to.be(3);
45+
expect(adapter.sockets(new Set(["r2"])).size).to.be(2);
46+
expect(adapter.sockets(new Set(["r4"])).size).to.be(0);
4747
});
4848

4949
it("should return a list of rooms", () => {
@@ -52,9 +52,9 @@ describe("socket.io-adapter", () => {
5252
adapter.addAll("s2", new Set(["r2", "r3"]));
5353
adapter.addAll("s3", new Set(["r3"]));
5454

55-
const rooms = adapter.clientRooms("s2");
55+
const rooms = adapter.socketRooms("s2");
5656
expect(rooms).to.be.a(Set);
5757
expect(rooms.size).to.be(2);
58-
expect(adapter.clientRooms("s4")).to.be(undefined);
58+
expect(adapter.socketRooms("s4")).to.be(undefined);
5959
});
6060
});

0 commit comments

Comments
 (0)