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

Method doClose

packages/engine.io/lib/transports-uws/polling.ts:387–410  ·  view source on GitHub ↗

* Closes the transport. * * @private

(fn)

Source from the content-addressed store, hash-verified

385 * @private
386 */
387 doClose(fn) {
388 debug("closing");
389
390 let closeTimeoutTimer;
391
392 const onClose = () => {
393 clearTimeout(closeTimeoutTimer);
394 fn();
395 this.onClose();
396 };
397
398 if (this.writable) {
399 debug("transport writable - closing right away");
400 this.send([{ type: "close" }]);
401 onClose();
402 } else if (this.discarded) {
403 debug("transport discarded - closing right away");
404 onClose();
405 } else {
406 debug("transport not writable - buffering orderly close");
407 this.shouldClose = onClose;
408 closeTimeoutTimer = setTimeout(onClose, this.closeTimeout);
409 }
410 }
411
412 /**
413 * Returns headers for a response.

Callers

nothing calls this directly

Calls 3

sendMethod · 0.95
debugFunction · 0.85
onCloseFunction · 0.50

Tested by

no test coverage detected