MCPcopy Index your code
hub / github.com/socketio/socket.io / registerAckCallback

Method registerAckCallback

lib/socket.ts:408–425  ·  view source on GitHub ↗

* @private

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

Source from the content-addressed store, hash-verified

406 * @private
407 */
408 private registerAckCallback(id: number, ack: (...args: any[]) => void): void {
409 const timeout = this.flags.timeout;
410 if (timeout === undefined) {
411 this.acks.set(id, ack);
412 return;
413 }
414
415 const timer = setTimeout(() => {
416 debug("event with ack id %d has timed out after %d ms", id, timeout);
417 this.acks.delete(id);
418 ack.call(this, new Error("operation has timed out"));
419 }, timeout);
420
421 this.acks.set(id, (...args) => {
422 clearTimeout(timer);
423 ack.apply(this, [null, ...args]);
424 });
425 }
426
427 /**
428 * Targets a room when broadcasting.

Callers 1

emitMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected