MCPcopy
hub / github.com/socketio/socket.io / #onClose

Method #onClose

examples/basic-websocket-client/src/index.js:157–180  ·  view source on GitHub ↗
(reason)

Source from the content-addressed store, hash-verified

155 }
156
157 #onClose(reason) {
158 if (this.#ws) {
159 this.#ws.onclose = noop;
160 this.#ws.close();
161 }
162
163 clearTimeout(this.#pingTimeoutTimer);
164 clearTimeout(this.#reconnectTimer);
165
166 if (this.connected) {
167 this.connected = false;
168 this.id = undefined;
169 super.emit("disconnect", reason);
170 } else {
171 super.emit("connect_error", reason);
172 }
173
174 if (this.#shouldReconnect) {
175 this.#reconnectTimer = setTimeout(
176 () => this.#open(),
177 this.#opts.reconnectionDelay
178 );
179 }
180 }
181
182 #resetPingTimeout() {
183 clearTimeout(this.#pingTimeoutTimer);

Callers 6

#openMethod · 0.95
#onMessageMethod · 0.95
#onOpenMethod · 0.95
#onPacketMethod · 0.95
#resetPingTimeoutMethod · 0.95
disconnectMethod · 0.95

Calls 3

#openMethod · 0.95
emitMethod · 0.65
closeMethod · 0.45

Tested by

no test coverage detected