diff --git a/src/electron/services/electronMainMessaging.service.ts b/src/electron/services/electronMainMessaging.service.ts new file mode 100644 index 0000000000..6e366147da --- /dev/null +++ b/src/electron/services/electronMainMessaging.service.ts @@ -0,0 +1,15 @@ +import { MessagingService } from '../../abstractions/messaging.service'; + +import { WindowMain } from '../window.main'; + +export class ElectronMainMessagingService implements MessagingService { + constructor(private windowMain: WindowMain, private onMessage: (message: any) => void) { } + + send(subscriber: string, arg: any = {}) { + const message = Object.assign({}, { command: subscriber }, arg); + this.onMessage(message); + if (this.windowMain.win != null) { + this.windowMain.win.webContents.send('messagingService', message); + } + } +}