Skip to content

Commit

Permalink
broadcast should support target window
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Dec 3, 2015
1 parent 9dd095c commit 2d44888
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
11 changes: 9 additions & 2 deletions src/vs/workbench/electron-main/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,16 @@ export class WindowsManager {
storage.setItem(WindowsManager.themeStorageKey, theme);
});

ipc.on('vscode:broadcast', (event: Event, windowId: number, broadcast: { channel: string; payload: any; }) => {
ipc.on('vscode:broadcast', (event: Event, windowId: number, target: string, broadcast: { channel: string; payload: any; }) => {
if (broadcast.channel && broadcast.payload) {
this.sendToAll('vscode:broadcast', broadcast, [windowId]);
if (target) {
let targetWindow = this.findWindow(target);
if (targetWindow && targetWindow.win.id !== windowId) {
targetWindow.send('vscode:broadcast', broadcast);
}
} else {
this.sendToAll('vscode:broadcast', broadcast, [windowId]);
}
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class PluginHostProcessManager {
payload: {
port: port
}
});
}, config.env.pluginDevelopmentPath /* target */);
}

// Messages from Plugin host
Expand Down Expand Up @@ -211,7 +211,7 @@ class PluginHostProcessManager {
this.windowService.broadcast({
channel: PLUGIN_LOG_BROADCAST_CHANNEL,
payload: logEntry
});
}, config.env.pluginDevelopmentPath /* target */);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface IWindowService {

registerWindow(win: ElectronWindow): void;

broadcast(b: IBroadcast): void;
broadcast(b: IBroadcast, target?: string): void;

onBroadcast: EventProvider<(b: IBroadcast) => void>;
}
Expand Down Expand Up @@ -72,8 +72,8 @@ export class WindowService implements IWindowService {
this.win = win;
}

public broadcast(b: IBroadcast): void {
ipc.send('vscode:broadcast', this.getWindowId(), {
public broadcast(b: IBroadcast, target?: string): void {
ipc.send('vscode:broadcast', this.getWindowId(), target, {
channel: b.channel,
payload: b.payload
});
Expand Down

0 comments on commit 2d44888

Please sign in to comment.