Is IPC for multiple windows possible or use "window.open" "window.opener.postMessage"


#1

I need to pass messages between 2 different renderer windows

I understand how to get a message to a renderer window from main, or call the function from a renderer window to main THEN main sends to a different window using “ipc.on” but this is still one-way communication, messages can only go to a single renderer window. But I really need to go back and forth --2 way-- between 2 render windows.

It appears that ipc.on is really just a single function and I cannot have multiple “ipc.on” type statements in the main.js? Otherwise I just use 1 “ipc on” call for one window and another ipc.on call for a different window? Doesn’t seem possible?

I tried the regular js “window.postMessage” for popup windows inside an Electron app but it seems to refuse to work due to security.

I was reading some about the Electron “window.open” function and “window.opener.postMessage” “BrowserWindowProxy.postMessage” and seems this is the Electron equivalent of the regular js window.postMessage function? I see the Electron page for this but like so many functions documentation with any actual code samples are hard to find.

So my questions.

  1. Can I do 2 way communication between 2 renderer windows just with IPC?
  2. Can I use Electron’s “Window Open” function to do this?
  3. If yes to either question any help on this would be awesome!!!