MCPcopy Create free account
hub / github.com/BUPT-GAMMA/MASFactory / close

Method close

masfactory-visualizer/src/runtime/wsServer.ts:126–141  ·  view source on GitHub ↗
(code = 1000, reason = '')

Source from the content-addressed store, hash-verified

124 }
125
126 public close(code = 1000, reason = ''): void {
127 if (this.closed) {return;}
128 this.closed = true;
129 try {
130 const reasonBuf = Buffer.from(reason, 'utf8');
131 const payload = Buffer.allocUnsafe(2 + reasonBuf.length);
132 payload.writeUInt16BE(code, 0);
133 reasonBuf.copy(payload, 2);
134 this.socket.write(encodeFrame(0x8, payload));
135 } catch {
136 // ignore
137 } finally {
138 this.emitCloseOnce();
139 this.socket.end();
140 }
141 }
142
143 private emitCloseOnce(): void {
144 if (this.closeEmitted) {return;}

Callers 3

onDataMethod · 0.95
closeMethod · 0.45
disposeMethod · 0.45

Calls 2

emitCloseOnceMethod · 0.95
encodeFrameFunction · 0.85

Tested by

no test coverage detected