MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / open

Method open

packages/server-e2e/src/ws.ts:71–100  ·  view source on GitHub ↗

Open the socket; resolves once `open` fires.

()

Source from the content-addressed store, hash-verified

69
70 /** Open the socket; resolves once `open` fires. */
71 async open(): Promise<void> {
72 if (this.ws) return;
73 await new Promise<void>((resolve, reject) => {
74 const ws = new this.opts.wsImpl(this.opts.url);
75 this.ws = ws;
76 ws.once('open', () => {
77 recordReportEvent(
78 { kind: 'ws', direction: 'lifecycle', url: this.opts.url, message: 'open' },
79 { reportDir: this.opts.reportDir },
80 );
81 resolve();
82 });
83 ws.once('error', (err) => {
84 if (this._closed) return;
85 recordReportEvent(
86 {
87 kind: 'ws',
88 direction: 'lifecycle',
89 url: this.opts.url,
90 message: 'error',
91 error: errorForReport(err),
92 },
93 { reportDir: this.opts.reportDir },
94 );
95 reject(err as Error);
96 });
97 ws.on('message', (data) => this._onMessage(data));
98 ws.on('close', (code, reason) => this._onClose(code, String(reason ?? '')));
99 });
100 }
101
102 /** JSON-stringifies and sends a frame. */
103 send(frame: object): void {

Callers 5

openSocketWithHelloFunction · 0.95
openSocketWithHelloFunction · 0.95
connectMethod · 0.95
report.test.tsFile · 0.45
readFileRangeFunction · 0.45

Calls 8

_onMessageMethod · 0.95
_onCloseMethod · 0.95
recordReportEventFunction · 0.85
rejectFunction · 0.85
errorForReportFunction · 0.70
onceMethod · 0.65
onMethod · 0.65
resolveFunction · 0.50

Tested by 1

openSocketWithHelloFunction · 0.76