Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor containers to use factory method for creating the message bus #178

Merged
merged 1 commit into from
Jul 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/Default/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export class DefaultContainer extends WebContainerBase {
super(win);
this.hostType = "Default";

this.ipc = new DefaultMessageBus(this);
this.ipc = this.createMessageBus();

// Create a global windows object for tracking all windows and add the current global window for current
if (this.globalWindow && !(DefaultContainer.windowsPropertyKey in this.globalWindow)) {
Expand All @@ -203,6 +203,10 @@ export class DefaultContainer extends WebContainerBase {
this.screen = new DefaultDisplayManager(this.globalWindow);
}

protected createMessageBus() : MessageBus {
return new DefaultMessageBus(this);
}

public getMainWindow(): ContainerWindow {
if (!this.mainWindow) {
this.mainWindow = new DefaultContainerWindow(this.globalWindow);
Expand Down
6 changes: 5 additions & 1 deletion src/Electron/electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export class ElectronContainer extends WebContainerBase {
this.menu = this.electron.Menu;

this.internalIpc = ipc || ((this.isRemote) ? require("electron").ipcRenderer : this.electron.ipcMain);
this.ipc = new ElectronMessageBus(this.internalIpc, this.browserWindow);
this.ipc = this.createMessageBus();

if (!this.isRemote || (options && typeof options.isRemote !== "undefined" && !options.isRemote)) {
this.windowManager = new ElectronWindowManager(this.app, this.internalIpc, this.browserWindow);
Expand All @@ -303,6 +303,10 @@ export class ElectronContainer extends WebContainerBase {
this.screen = new ElectronDisplayManager(this.electron);
}

protected createMessageBus() : MessageBus {
return new ElectronMessageBus(this.internalIpc, this.browserWindow);
}

protected registerNotificationsApi() {
if (typeof this.globalWindow !== "undefined" && this.globalWindow) {
// Define owningContainer for closure to inner class
Expand Down
6 changes: 5 additions & 1 deletion src/OpenFin/openfin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ export class OpenFinContainer extends WebContainerBase {
this.desktop.Application.getCurrent().registerUser(options.userName, options.appName);
}

this.ipc = new OpenFinMessageBus(this.desktop.InterApplicationBus, (<any>this.desktop.Application.getCurrent()).uuid);
this.ipc = this.createMessageBus();

let replaceNotificationApi = OpenFinContainer.replaceNotificationApi;
if (options && typeof options.replaceNotificationApi !== "undefined") {
Expand All @@ -366,6 +366,10 @@ export class OpenFinContainer extends WebContainerBase {
this.screen = new OpenFinDisplayManager(this.desktop);
}

protected createMessageBus() : MessageBus {
return new OpenFinMessageBus(this.desktop.InterApplicationBus, (<any>this.desktop.Application.getCurrent()).uuid);
}

protected registerNotificationsApi() {
if (typeof this.globalWindow !== "undefined" && this.globalWindow) {
// Define owningContainer for closure to inner class
Expand Down
3 changes: 3 additions & 0 deletions src/desktop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Container } from "./container";
import { ContainerNotification } from "./notification";
import { ObjectTransform } from "./propertymapping";
import { ContainerWindow, WindowStateTracking, GroupWindowManager, SnapAssistWindowManager } from "./window";
import { MessageBusSubscription, MessageBusOptions } from "./ipc";
import * as Default from "./Default/default";
import * as Electron from "./Electron/electron";
import * as OpenFin from "./OpenFin/openfin";
Expand All @@ -21,4 +22,6 @@ export default class Desktop { //tslint:disable-line
static get WindowStateTracking(): typeof WindowStateTracking { return WindowStateTracking; }
static get GroupWindowManager(): typeof GroupWindowManager { return GroupWindowManager; }
static get SnapAssistWindowManager(): typeof SnapAssistWindowManager { return SnapAssistWindowManager; }
static get MessageBusSubscription(): typeof MessageBusSubscription { return MessageBusSubscription; }
static get MessageBusOptions(): typeof MessageBusOptions { return MessageBusOptions; }
}