MCPcopy
hub / github.com/socketio/socket.io / subscribe

Function subscribe

packages/socket.io/lib/uws.ts:94–113  ·  view source on GitHub ↗
(
  namespaceName: string,
  socket: Socket,
  isNew: boolean,
  rooms: Set<Room>,
)

Source from the content-addressed store, hash-verified

92}
93
94function subscribe(
95 namespaceName: string,
96 socket: Socket,
97 isNew: boolean,
98 rooms: Set<Room>,
99) {
100 // @ts-ignore
101 const sessionId = socket.conn.id;
102 // @ts-ignore
103 const websocket: WebSocket = socket.conn.transport.socket;
104 if (isNew) {
105 debug("subscribe connection %s to topic %s", sessionId, namespaceName);
106 websocket.subscribe(namespaceName);
107 }
108 rooms.forEach((room) => {
109 const topic = `${namespaceName}${SEPARATOR}${room}`; // '#' can be used as wildcard
110 debug("subscribe connection %s to topic %s", sessionId, topic);
111 websocket.subscribe(topic);
112 });
113}
114
115export function restoreAdapter() {
116 Adapter.prototype.addAll = addAll;

Callers 1

patchAdapterFunction · 0.85

Calls 1

debugFunction · 0.85

Tested by

no test coverage detected