diff --git a/src/Default/default.ts b/src/Default/default.ts index 303df8cf..855725f1 100644 --- a/src/Default/default.ts +++ b/src/Default/default.ts @@ -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)) { @@ -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); diff --git a/src/Electron/electron.ts b/src/Electron/electron.ts index 0c9813bc..5cf7cead 100644 --- a/src/Electron/electron.ts +++ b/src/Electron/electron.ts @@ -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); @@ -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 diff --git a/src/OpenFin/openfin.ts b/src/OpenFin/openfin.ts index 3cb03ea4..e0ff22d3 100644 --- a/src/OpenFin/openfin.ts +++ b/src/OpenFin/openfin.ts @@ -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, (this.desktop.Application.getCurrent()).uuid); + this.ipc = this.createMessageBus(); let replaceNotificationApi = OpenFinContainer.replaceNotificationApi; if (options && typeof options.replaceNotificationApi !== "undefined") { @@ -366,6 +366,10 @@ export class OpenFinContainer extends WebContainerBase { this.screen = new OpenFinDisplayManager(this.desktop); } + protected createMessageBus() : MessageBus { + return new OpenFinMessageBus(this.desktop.InterApplicationBus, (this.desktop.Application.getCurrent()).uuid); + } + protected registerNotificationsApi() { if (typeof this.globalWindow !== "undefined" && this.globalWindow) { // Define owningContainer for closure to inner class diff --git a/src/desktop.ts b/src/desktop.ts index e074ed7f..2a75b5b7 100644 --- a/src/desktop.ts +++ b/src/desktop.ts @@ -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"; @@ -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; } }