MCPcopy
hub / github.com/audreyt/ethercalc / closeSession

Function closeSession

packages/socketio-shim/src/adapter.ts:211–233  ·  view source on GitHub ↗
(sid: string, reason = 'closed')

Source from the content-addressed store, hash-verified

209 }
210
211 function closeSession(sid: string, reason = 'closed'): void {
212 const session = sessions.get(sid);
213 if (!session) return;
214 if (session.hbTimer !== null) {
215 clearTimer(session.hbTimer);
216 session.hbTimer = null;
217 }
218 if (session.ws) {
219 try {
220 session.ws.close(1000, reason);
221 } catch {
222 // Close may throw if already closed; that's fine.
223 }
224 session.ws = null;
225 }
226 if (session.pollResolver) {
227 const resolve = session.pollResolver;
228 session.pollResolver = null;
229 // Emit a disconnect frame so the polling client tears down.
230 resolve(encodeFrame({ type: PacketType.Disconnect }));
231 }
232 sessions.delete(sid);
233 }
234
235 return {
236 handleHandshake(request: Request): Response {

Callers 1

processInboundFrameFunction · 0.85

Calls 4

encodeFrameFunction · 0.90
clearTimerFunction · 0.85
closeMethod · 0.65
resolveFunction · 0.50

Tested by

no test coverage detected