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

Commit 32f3c79

Browse files
Merge branch 'dev' into users/t-xunguy/fix-merge
2 parents 4d42d49 + 74491dd commit 32f3c79

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/debuggerCommunicationServer.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as http from "http";
55
import * as socketio from "socket.io";
66
import { WebviewPanel } from "vscode";
77
import { SERVER_INFO } from "./constants";
8+
import { DeviceSelectionService } from "./service/deviceSelectionService";
89

910
export const DEBUGGER_MESSAGES = {
1011
EMITTER: {
@@ -24,14 +25,14 @@ export class DebuggerCommunicationServer {
2425
private serverHttp: http.Server;
2526
private serverIo: socketio.Server;
2627
private simulatorWebview: WebviewPanel | undefined;
27-
private currentActiveDevice;
28+
private deviceSelectionService: DeviceSelectionService;
2829
private isPendingResponse = false;
2930
private pendingCallbacks: Function[] = [];
3031

3132
constructor(
3233
webviewPanel: WebviewPanel | undefined,
3334
port = SERVER_INFO.DEFAULT_SERVER_PORT,
34-
currentActiveDevice: string
35+
deviceSelectionService: DeviceSelectionService
3536
) {
3637
this.port = port;
3738
this.serverHttp = new http.Server();
@@ -42,7 +43,7 @@ export class DebuggerCommunicationServer {
4243
this.initEventsHandlers();
4344
console.info(`Server running on port ${this.port}`);
4445

45-
this.currentActiveDevice = currentActiveDevice;
46+
this.deviceSelectionService = deviceSelectionService;
4647
}
4748

4849
// send the message to start closing the connection
@@ -119,12 +120,16 @@ export class DebuggerCommunicationServer {
119120
try {
120121
const messageToWebview = JSON.parse(data);
121122
if (messageToWebview.type === "state") {
122-
console.log(`State recieved: ${messageToWebview.data}`);
123-
if (this.simulatorWebview) {
123+
const messageState = JSON.parse(messageToWebview.data);
124+
if (
125+
this.simulatorWebview &&
126+
messageState.device_name ===
127+
this.deviceSelectionService.getCurrentActiveDevice()
128+
) {
124129
this.simulatorWebview.webview.postMessage({
125-
active_device: this.currentActiveDevice,
130+
active_device: this.deviceSelectionService.getCurrentActiveDevice(),
126131
command: "set-state",
127-
state: JSON.parse(messageToWebview.data),
132+
state: messageState,
128133
});
129134
}
130135
}

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ export async function activate(context: vscode.ExtensionContext) {
947947
new DebuggerCommunicationServer(
948948
currentPanel,
949949
utils.getServerPortConfig(),
950-
deviceSelectionService.getCurrentActiveDevice()
950+
deviceSelectionService
951951
)
952952
);
953953

0 commit comments

Comments
 (0)