Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to communicate between multiple electron main processes?

Tags:

I know the electron ipc module allows one main process to communicate with multiple render process. On top of this, is there a way to use another main process to communicate with multiple main processes simultaneously?

like image 244
user3669481 Avatar asked Mar 27 '16 02:03

user3669481


People also ask

How do two electron Windows communicate?

You actually can communicate between 2 Electron windows via JS if you open the popup window from the renderer process of the main window, by using window. open(). This avoids the need to communicate via IPC calls.

How does IPC work in electron?

IPC channels​ In Electron, processes communicate by passing messages through developer-defined "channels" with the ipcMain and ipcRenderer modules. These channels are arbitrary (you can name them anything you want) and bidirectional (you can use the same channel name for both modules).

What is ipcMain?

The ipcMain module is an Event Emitter. When used in the main process, it handles asynchronous and synchronous messages sent from a renderer process (web page). Messages sent from a renderer will be emitted to this module. For usage examples, check out the IPC tutorial.

What is Nodeintegration electron?

Electron node integration refers to the ability of accessing Node. js resources from within the “renderer” thread (the UI). It is enabled by default in Quasar CLI, although Electron is encouraging developers to turn it off as a security precaution.


1 Answers

As far as I know there is no built-in facility for doing this in Electron. That being said, the answer to your question is the same as the answer to the broader question of how to do inter process communication in Node.js, to which there are multiple answers. You can use sockets directly, file passing, databases, messaging systems, Redis, etc...

This question: What's the most efficient node.js inter-process communication library/method? provides some possible answers. One of the answers points to the node-ipc project on GitHub: https://github.com/RIAEvangelist/node-ipc. This particular solution appears to use sockets to pass the messages.

like image 168
Shawn Rakowski Avatar answered Nov 15 '22 06:11

Shawn Rakowski