Electron send message/event to meteor client

I implemented a simple electron application that loads my application using win.loadURL(‘http://app.com:3000’) and now the application works as if it was in a browser, which is what I wanted.
Sometimes I need to send from electron main to my meteor client a message/event and on this event I need my client to perform an action, e.g. Router.go(‘foo’).
I tried the example from https://www.electronjs.org/docs/api/ipc-main but I am not too sure how can I implement the renderer in my meteor code.

Any help would be greatly appreciated.

Hi Adid, welcome to the Meteor forums!

This works for me:

// desktop.js - Electron code

export default class Desktop {
    constructor({log, skeletonApp, appSettings, eventsBus, modules, Module}) {
        const desktop = new Module('desktop');
        // make renderer go somewhere
        desktop.send('routerGo', path);

// Anywhere in your meteor code.... (wherever Router is defined). 

if (Meteor.isDesktop) {
    Desktop.on('desktop', 'routerGo', (e, path) => Router.go(path) );

This page explains it all: https://github.com/wojtkowiak/meteor-desktop#desktop-and-module

1 Like