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

Commit

Permalink
Merge branch 'dev' into users/t-xunguy/tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
xnkevinnguyen authored Apr 22, 2020
2 parents 858e0ae + 74491dd commit 8891028
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 12 additions & 7 deletions src/debuggerCommunicationServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as http from "http";
import * as socketio from "socket.io";
import { WebviewPanel } from "vscode";
import { SERVER_INFO } from "./constants";
import { DeviceSelectionService } from "./service/deviceSelectionService";

export const DEBUGGER_MESSAGES = {
EMITTER: {
Expand All @@ -24,14 +25,14 @@ export class DebuggerCommunicationServer {
private serverHttp: http.Server;
private serverIo: socketio.Server;
private simulatorWebview: WebviewPanel | undefined;
private currentActiveDevice;
private deviceSelectionService: DeviceSelectionService;
private isPendingResponse = false;
private pendingCallbacks: Function[] = [];

constructor(
webviewPanel: WebviewPanel | undefined,
port = SERVER_INFO.DEFAULT_SERVER_PORT,
currentActiveDevice: string
deviceSelectionService: DeviceSelectionService
) {
this.port = port;
this.serverHttp = new http.Server();
Expand All @@ -42,7 +43,7 @@ export class DebuggerCommunicationServer {
this.initEventsHandlers();
console.info(`Server running on port ${this.port}`);

this.currentActiveDevice = currentActiveDevice;
this.deviceSelectionService = deviceSelectionService;
}

// send the message to start closing the connection
Expand Down Expand Up @@ -119,12 +120,16 @@ export class DebuggerCommunicationServer {
try {
const messageToWebview = JSON.parse(data);
if (messageToWebview.type === "state") {
console.log(`State recieved: ${messageToWebview.data}`);
if (this.simulatorWebview) {
const messageState = JSON.parse(messageToWebview.data);
if (
this.simulatorWebview &&
messageState.device_name ===
this.deviceSelectionService.getCurrentActiveDevice()
) {
this.simulatorWebview.webview.postMessage({
active_device: this.currentActiveDevice,
active_device: this.deviceSelectionService.getCurrentActiveDevice(),
command: "set-state",
state: JSON.parse(messageToWebview.data),
state: messageState,
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ export async function activate(context: vscode.ExtensionContext) {
new DebuggerCommunicationServer(
currentPanel,
utils.getServerPortConfig(),
deviceSelectionService.getCurrentActiveDevice()
deviceSelectionService
)
);

Expand Down

0 comments on commit 8891028

Please sign in to comment.