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

Commit 78821fb

Browse files
committed
Merge branch 'users/t-anmah/debugger' of https://github.com/microsoft/vscode-python-devicesimulator into users/t-anmah/debugger
2 parents 79187f4 + 997cf2a commit 78821fb

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/debuggerCommunicationServer.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ export class DebuggerCommunicationServer {
2525
private serverIo: socketio.Server;
2626
private simulatorWebview: WebviewPanel | undefined;
2727
private currentActiveDevice;
28-
private isWaitingResponse = false;
29-
private currentCall: Array<Function> = [];
28+
private isPendingResponse = false;
29+
private pendingCallbacks: Array<Function> = [];
3030

3131
constructor(
3232
webviewPanel: WebviewPanel | undefined,
@@ -54,22 +54,21 @@ export class DebuggerCommunicationServer {
5454
public setWebview(webviewPanel: WebviewPanel | undefined) {
5555
this.simulatorWebview = webviewPanel;
5656
}
57-
57+
// Events are pushed when the previous processed event is over
5858
public emitInputChanged(newState: string): void {
59-
if (this.isWaitingResponse) {
60-
this.currentCall.push(() => {
59+
if (this.isPendingResponse) {
60+
this.pendingCallbacks.push(() => {
6161
this.serverIo.emit(
6262
DEBUGGER_MESSAGES.EMITTER.INPUT_CHANGED,
6363
newState
6464
);
65-
this.isWaitingResponse = true;
6665
});
6766
} else {
6867
this.serverIo.emit(
6968
DEBUGGER_MESSAGES.EMITTER.INPUT_CHANGED,
7069
newState
7170
);
72-
this.isWaitingResponse = true;
71+
this.isPendingResponse = true;
7372
}
7473
}
7574

@@ -90,10 +89,12 @@ export class DebuggerCommunicationServer {
9089
);
9190
});
9291
socket.on(DEBUGGER_MESSAGES.LISTENER.RECEIVED_STATE, () => {
93-
this.isWaitingResponse = false;
94-
if (this.currentCall.length > 0) {
95-
let currentCall = this.currentCall.shift();
92+
if (this.pendingCallbacks.length > 0) {
93+
const currentCall = this.pendingCallbacks.shift();
9694
currentCall();
95+
this.isPendingResponse = true;
96+
} else {
97+
this.isPendingResponse = false;
9798
}
9899
});
99100

0 commit comments

Comments
 (0)