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

Method registerAckCallback

packages/socket.io/lib/socket.ts:315–332  ·  view source on GitHub ↗

* @private

(id: number, ack: (...args: any[]) => void)

Source from the content-addressed store, hash-verified

313 * @private
314 */
315 private registerAckCallback(id: number, ack: (...args: any[]) => void): void {
316 const timeout = this.flags.timeout;
317 if (timeout === undefined) {
318 this.acks.set(id, ack);
319 return;
320 }
321
322 const timer = setTimeout(() => {
323 debug("event with ack id %d has timed out after %d ms", id, timeout);
324 this.acks.delete(id);
325 ack.call(this, new Error("operation has timed out"));
326 }, timeout);
327
328 this.acks.set(id, (...args) => {
329 clearTimeout(timer);
330 ack.apply(this, [null, ...args]);
331 });
332 }
333
334 /**
335 * Targets a room when broadcasting.

Callers 1

emitMethod · 0.95

Calls 2

debugFunction · 0.85
applyMethod · 0.80

Tested by

no test coverage detected