Skip to content
This repository was archived by the owner on Dec 23, 2021. It is now read-only.

Commit c6e535e

Browse files
committed
Send message to python side on disconnect from vscode server side
1 parent 9d3265e commit c6e535e

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/debugger/debugAdapter.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { DebugAdapterTracker, DebugConsole, DebugSession } from "vscode";
22
import { MessagingService } from "../service/messagingService";
33
import { DEBUG_COMMANDS } from "../view/constants";
4+
import { DebuggerCommunicationServer } from "../debuggerCommunicationServer";
45

56
export class DebugAdapter implements DebugAdapterTracker {
67
private readonly console: DebugConsole | undefined;
@@ -32,8 +33,8 @@ export class DebugAdapter implements DebugAdapterTracker {
3233
onError() {
3334
this.messagingService.sendStartMessage();
3435
}
35-
// Device is always running when exiting debugging mode
3636
onExit() {
37+
// Device is always running when exiting debugging mode
3738
this.messagingService.sendStartMessage();
3839
}
3940
}

src/debuggerCommunicationServer.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export const DEBUGGER_MESSAGES = {
1111
INPUT_CHANGED: "input_changed",
1212
RECEIVED_STATE: "received_state",
1313
DISCONNECT: "process_disconnect",
14-
1514
},
1615
LISTENER: {
1716
UPDATE_STATE: "updateState",
@@ -47,6 +46,7 @@ export class DebuggerCommunicationServer {
4746
}
4847

4948
public closeConnection(): void {
49+
this.disconnectSocketIo();
5050
this.serverIo.close();
5151
this.serverHttp.close();
5252
console.info("Closing the server");
@@ -108,6 +108,9 @@ export class DebuggerCommunicationServer {
108108
});
109109
});
110110
}
111+
public disconnectSocketIo() {
112+
this.serverIo.emit(DEBUGGER_MESSAGES.EMITTER.DISCONNECT, {});
113+
}
111114

112115
private handleState(data: any): void {
113116
try {

src/service/messagingService.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ export class MessagingService {
1414
this.currentWebviewTarget.postMessage({ command: debugCommand });
1515
}
1616
}
17-
public sendDebuggerExitMessage() {
18-
this.currentWebviewTarget.postMessage({
19-
command: DEBUGGER_MESSAGES.EMITTER.DISCONNECT,
20-
});
21-
}
17+
2218
public sendStartMessage() {
2319
this.currentWebviewTarget.postMessage({
2420
command: VSCODE_MESSAGES_TO_WEBVIEW.RUN_DEVICE,

0 commit comments

Comments
 (0)