MCPcopy Create free account
hub / github.com/Marus/cortex-debug / connectToSource

Method connectToSource

src/frontend/rtt_terminal.ts:32–59  ·  view source on GitHub ↗
(src: SocketRTTSource)

Source from the content-addressed store, hash-verified

30 }
31
32 private connectToSource(src: SocketRTTSource) {
33 this.hrTimer = new HrTimer();
34 this.binaryFormatter = new BinaryFormatter(this.ptyTerm, this.options.encoding, this.options.scale);
35 src.once('disconnected', () => { this.onClose(); });
36 src.on('error', (e) => {
37 const code: string = (e as any).code;
38 if (code === 'ECONNRESET') {
39 // Server closed the connection. We are done with this session
40 } else if (code === 'ECONNREFUSED') {
41 // We expect 'ECONNREFUSED' if the server has not yet started after all the retries
42 magentaWrite(`${e}\n.`, this.ptyTerm);
43 } else {
44 magentaWrite(`${e}\n`, this.ptyTerm);
45 }
46 });
47 src.on('data', (data) => { this.onData(data); });
48
49 if (src.connError) {
50 this.source = src;
51 magentaWrite(`${src.connError.message}\n`, this.ptyTerm);
52 } else if (src.connected) {
53 this.source = src;
54 } else {
55 src.once('connected', () => {
56 this.source = src;
57 });
58 }
59 }
60
61 private onClose() {
62 this.source = null;

Callers 2

constructorMethod · 0.95
tryReuseMethod · 0.95

Calls 3

onCloseMethod · 0.95
onDataMethod · 0.95
magentaWriteFunction · 0.90

Tested by

no test coverage detected