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

Communicate between apps #2007

Closed
iamdriz opened this Issue Jun 18, 2015 · 6 comments

Comments

Projects
None yet
4 participants
@iamdriz

iamdriz commented Jun 18, 2015

If I have two Electron apps running, can I send messages between them?

@maxkueng

This comment has been minimized.

maxkueng commented Jun 18, 2015

I'm with @frankhale on this. Electron apps can communicate with each other the same way any Node.js apps can communicate together.

Depending on whether your two apps are on the same host, the same network, or different networks you may choose different technologies.

@zcbenz

This comment has been minimized.

Contributor

zcbenz commented Jun 19, 2015

The popular way is named pipe or file socket.

@zcbenz zcbenz closed this Jun 19, 2015

@iamdriz

This comment has been minimized.

iamdriz commented Jul 1, 2015

I'm struggling to understand this... basically if I have the following applications running:

Dashboard.exe
Game1.exe
Game2.exe
Game3.exe

And I fire an event inside Game3.exe, I want Dashboard.exe to react to this event.

According to the stackoverflow question shared by @frankhale http://stackoverflow.com/questions/10213501/node-js-communicating-between-two-different-processes

To listen and send messages across processes you can delcare it via the fork... e.g.

var fork = require('child_process').fork;
var example1 = fork(__dirname + '/example1.js');

And then I can use example1 to send it messages... However is that not assuming that I have launched the process/exe from one of the other processes? Rather than both were called individually or were already running...

Can someone put together a quick example of how to Electron EXEs could talk to each other?

@iamdriz

This comment has been minimized.

iamdriz commented Jul 1, 2015

I'm going to look at giving this a try: https://github.com/weixiyen/messenger.js as it seems to do what I want... will report back here with results.

@iamdriz

This comment has been minimized.

iamdriz commented Jul 1, 2015

Boom! I can confirm that Messenger.js is exactly what I need! It doesn't matter who or when the apps were opened so long as they all listen on the same port they can communicate :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment