You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// "mdpk4kxF5CmhwfCdAHD8" being the ID of the given socket
107
+
```
108
+
109
+
Those two Maps are then used when broadcasting:
110
+
111
+
- a broadcast to all sockets (`io.emit()`) loops through the `sids` Map, and send the packet to all sockets
112
+
- a broadcast to a given room (`io.to("room21").emit()`) loops through the Set in the `rooms` Map, and sends the packet to all matching sockets
113
+
114
+
The Redis adapter extends the broadcast function of the in-memory adapter: the packet is also [published](https://redis.io/topics/pubsub) to a Redis channel (see [below](#protocol) for the format of the channel name).
115
+
116
+
Each Socket.IO server receives this packet and broadcasts it to its own list of connected sockets.
117
+
118
+
To check what's happening on your Redis instance:
119
+
120
+
```
121
+
$ redis-cli
122
+
127.0.0.1:6379> PSUBSCRIBE *
123
+
Reading messages... (press Ctrl-C to quit)
124
+
1) "psubscribe"
125
+
2) "*"
126
+
3) (integer) 1
127
+
128
+
1) "pmessage"
129
+
2) "*"
130
+
3) "socket.io#/#" (a broadcast to all sockets or to a list of rooms)
131
+
4) <the packet content>
132
+
133
+
1) "pmessage"
134
+
2) "*"
135
+
3) "socket.io#/#room21#" (a broadcast to a single room)
The request and response channels are used in the additional methods exposed by the Redis adapter, like [RedisAdapter#allRooms()](#redisadapterallrooms).
0 commit comments