ipc.net.ts ×14

Frontier kind: Code frontier

unlabeled · c_3bf7142a3904

9 tests · 10136 LOC · 54 files · introduces 0 tests · 101 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
14 ranges101 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1457 ranges10136 lines · 54 files · Browse complete extent
All tests (intent)
9 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 101 introduced LOC across 14 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/base/parts/ipc/common/ipc.net.ts 101 introduced LOC · 14 ranges

Open complete file

273 }
274
275 > function protocolMessageTypeToString(messageType: ProtocolMessageType) { ipc.net.ts
276 > switch (messageType) {
277 > case ProtocolMessageType.None: return 'None';
278 > case ProtocolMessageType.Regular: return 'Regular';
279 > case ProtocolMessageType.Control: return 'Control';
280 > case ProtocolMessageType.Ack: return 'Ack';
281 > case ProtocolMessageType.Disconnect: return 'Disconnect';
282 > case ProtocolMessageType.ReplayRequest: return 'ReplayRequest';
283 > case ProtocolMessageType.Pause: return 'PauseWriting';
284 > case ProtocolMessageType.Resume: return 'ResumeWriting';
285 > case ProtocolMessageType.KeepAlive: return 'KeepAlive';
286 > }
287 > }
288
289 export const enum ProtocolConstants {
318
319 constructor(
320 > public readonly type: ProtocolMessageType, ipc.net.ts
321 > public readonly id: number,
322 > public readonly ack: number,
323 > public readonly data: VSBuffer
324 > ) {
325 > this.writtenTime = 0;
326 > }
327
328 public get size(): number {
359
360 public acceptChunk(data: VSBuffer | null): void {
361 > if (!data || data.byteLength === 0) { ipc.net.ts
362 return;
363 }
364 > ipc.net.ts
365 > this.lastReadTime = Date.now();
366 >
367 > this._incomingData.acceptChunk(data);
368 >
369 > while (this._incomingData.byteLength >= this._state.readLen) {
370 >
371 > const buff = this._incomingData.read(this._state.readLen);
372 >
373 > if (this._state.readHead) {
374 > // buff is the header
375 >
376 > // save new state => next time will read the body
377 > this._state.readHead = false;
378 > this._state.readLen = buff.readUInt32BE(9);
379 > this._state.messageType = buff.readUInt8(0);
380 > this._state.id = buff.readUInt32BE(1);
381 > this._state.ack = buff.readUInt32BE(5);
382 >
383 > this._socket.traceSocketEvent(SocketDiagnosticsEventType.ProtocolHeaderRead, { messageType: protocolMessageTypeToString(this._state.messageType), id: this._state.id, ack: this._state.ack, messageSize: this._state.readLen });
384 >
385 > } else {
386 > // buff is the body
387 > const messageType = this._state.messageType;
388 > const id = this._state.id;
389 > const ack = this._state.ack;
390 >
391 > // save new state => next time will read the header
392 > this._state.readHead = true;
393 > this._state.readLen = ProtocolConstants.HeaderLength;
394 > this._state.messageType = ProtocolMessageType.None;
395 > this._state.id = 0;
396 > this._state.ack = 0;
397 >
398 > this._socket.traceSocketEvent(SocketDiagnosticsEventType.ProtocolMessageRead, buff);
399 >
400 > this._onMessage.fire(new ProtocolMessage(messageType, id, ack, buff));
401 >
402 > if (this._isDisposed) {
403 // check if an event listener lead to our disposal
404 break;
405 }
406 > } ipc.net.ts
407 > }
408 > }
409
410 public readEntireBuffer(): VSBuffer {
465
466 public write(msg: ProtocolMessage) {
467 > if (this._isDisposed) { ipc.net.ts
468 // ignore: there could be left-over promises which complete and then
469 // decide to write a response, etc...
470 return;
471 }
472 > msg.writtenTime = Date.now(); ipc.net.ts
473 > this.lastWriteTime = Date.now();
474 > const header = VSBuffer.alloc(ProtocolConstants.HeaderLength);
475 > header.writeUInt8(msg.type, 0);
476 > header.writeUInt32BE(msg.id, 1);
477 > header.writeUInt32BE(msg.ack, 5);
478 > header.writeUInt32BE(msg.data.byteLength, 9);
479 >
480 > this._socket.traceSocketEvent(SocketDiagnosticsEventType.ProtocolHeaderWrite, { messageType: protocolMessageTypeToString(msg.type), id: msg.id, ack: msg.ack, messageSize: msg.data.byteLength });
481 > this._socket.traceSocketEvent(SocketDiagnosticsEventType.ProtocolMessageWrite, msg.data);
482 >
483 > this._writeSoon(header, msg.data);
484 > }
485
486 private _bufferAdd(head: VSBuffer, body: VSBuffer): boolean {
487 > const wasEmpty = this._totalLength === 0; ipc.net.ts
488 > this._data.push(head, body);
489 > this._totalLength += head.byteLength + body.byteLength;
490 > return wasEmpty;
491 > }
492
493 private _bufferTake(): VSBuffer {
494 > const ret = VSBuffer.concat(this._data, this._totalLength); ipc.net.ts
495 > this._data.length = 0;
496 > this._totalLength = 0;
497 > return ret;
498 > }
499
500 private _writeSoon(header: VSBuffer, data: VSBuffer): void {
501 > if (this._bufferAdd(header, data)) { ipc.net.ts
502 > this._scheduleWriting();
503 > }
504 > }
505
506 private _writeNowTimeout: Timeout | null = null;
507 private _scheduleWriting(): void {
508 > if (this._writeNowTimeout) { ipc.net.ts
509 return;
510 }
511 > this._writeNowTimeout = setTimeout(() => { ipc.net.ts
512 > this._writeNowTimeout = null;
513 > this._writeNow();
514 > });
515 > }
516
517 private _writeNow(): void {
519 return;
520 }
521 > if (this._isPaused) { ipc.net.ts
522 return;
523 }
524 > const data = this._bufferTake(); ipc.net.ts
525 > this._socket.traceSocketEvent(SocketDiagnosticsEventType.ProtocolWrite, { byteLength: data.byteLength });
526 > this._socket.write(data);
527 }
528 }