@@ -25,8 +25,8 @@ export class DebuggerCommunicationServer {
25
25
private serverIo : socketio . Server ;
26
26
private simulatorWebview : WebviewPanel | undefined ;
27
27
private currentActiveDevice ;
28
- private isWaitingResponse = false ;
29
- private currentCall : Array < Function > = [ ] ;
28
+ private isPendingResponse = false ;
29
+ private pendingCallbacks : Array < Function > = [ ] ;
30
30
31
31
constructor (
32
32
webviewPanel : WebviewPanel | undefined ,
@@ -54,22 +54,21 @@ export class DebuggerCommunicationServer {
54
54
public setWebview ( webviewPanel : WebviewPanel | undefined ) {
55
55
this . simulatorWebview = webviewPanel ;
56
56
}
57
-
57
+ // Events are pushed when the previous processed event is over
58
58
public emitInputChanged ( newState : string ) : void {
59
- if ( this . isWaitingResponse ) {
60
- this . currentCall . push ( ( ) => {
59
+ if ( this . isPendingResponse ) {
60
+ this . pendingCallbacks . push ( ( ) => {
61
61
this . serverIo . emit (
62
62
DEBUGGER_MESSAGES . EMITTER . INPUT_CHANGED ,
63
63
newState
64
64
) ;
65
- this . isWaitingResponse = true ;
66
65
} ) ;
67
66
} else {
68
67
this . serverIo . emit (
69
68
DEBUGGER_MESSAGES . EMITTER . INPUT_CHANGED ,
70
69
newState
71
70
) ;
72
- this . isWaitingResponse = true ;
71
+ this . isPendingResponse = true ;
73
72
}
74
73
}
75
74
@@ -90,10 +89,12 @@ export class DebuggerCommunicationServer {
90
89
) ;
91
90
} ) ;
92
91
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 ( ) ;
96
94
currentCall ( ) ;
95
+ this . isPendingResponse = true ;
96
+ } else {
97
+ this . isPendingResponse = false ;
97
98
}
98
99
} ) ;
99
100
0 commit comments