Reputation: 4014
I'm trying to send message/data from ipcMain to ipcRender asynchronously, followed the codes described there - https://electronjs.org/docs/api/ipc-main, In main -
// In main process.
const {ipcMain} = require('electron')
ipcMain.on('asynchronous-message', (event, arg) => {
console.log(arg) // prints "ping"
event.sender.send('asynchronous-reply', 'pong')
})
In renderer -
// In renderer process (web page).
const {ipcRenderer} = require('electron')
ipcRenderer.on('asynchronous-reply', (event, arg) => {
console.log(arg) // prints "pong"
})
ipcRenderer.send('asynchronous-message', 'ping')
It sends message from renderer to main successfully, but main suppose to send back message to renderer but it doesn't.
I've tried webContents send message too but no success -
win.webContents.send('asynchronous-reply', 'pong1')
I'm using using node 8.9.3, Chrome 61.0.3163.100, Electron 2.0.5 and macOS 10.13.3. Here are the details - https://github.com/electron/electron/issues/13743
Appreciate any help. Thanks
Upvotes: 1
Views: 2026
Reputation: 4014
Thanks @ancode. Figured it out, The messages sent from Renderer to Main was printing in Terminal Console and message sent from Main to Renderer was printing in Web Dev Console(As a new electron developer, I completely missed it, was expecting all messages in Terminal Console)
Upvotes: 2