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

Method constructor

packages/socket.io-cluster-engine/lib/redis.ts:137–164  ·  view source on GitHub ↗
(pubClient: any, subClient: any, opts?: RedisEngineOptions)

Source from the content-addressed store, hash-verified

135 private readonly _channelPrefix: string;
136
137 constructor(pubClient: any, subClient: any, opts?: RedisEngineOptions) {
138 super(opts);
139 this._pubClient = pubClient;
140 this._channelPrefix = opts?.channelPrefix || "engine.io";
141 const channels = [
142 channelName(this._channelPrefix),
143 channelName(this._channelPrefix, this._nodeId),
144 ];
145
146 debug("subscribing to redis channels: %s", channels);
147 SUBSCRIBE(subClient, channels, (buffer: Buffer) => {
148 let message: Message & { _source?: string; _primaryId?: string };
149 try {
150 message = decode(buffer) as Message;
151 } catch (e) {
152 debug("ignore malformed buffer");
153 return;
154 }
155
156 if (message._source !== MESSAGE_SOURCE) {
157 debug("ignore message from unknown source");
158 return;
159 }
160
161 debug("received message: %j", message);
162 this.onMessage(message);
163 });
164 }
165
166 publishMessage(message: Message & { _source?: string }): void {
167 // @ts-expect-error recipientId is not defined for all messages

Callers

nothing calls this directly

Calls 4

channelNameFunction · 0.85
debugFunction · 0.85
SUBSCRIBEFunction · 0.85
decodeFunction · 0.50

Tested by

no test coverage detected