Use ipcRenderer.sendTo to get rid of routers in main process
This commit is contained in:
parent
a58b84bbd7
commit
ba315248e0
5 changed files with 33 additions and 50 deletions
|
@ -352,12 +352,16 @@ ipcMain.on('ELECTRON_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', function (event, request
|
|||
}
|
||||
})
|
||||
|
||||
ipcMain.on('ELECTRON_BROWSER_SEND_TO', function (event, webContentsId, channel, ...args) {
|
||||
ipcMain.on('ELECTRON_BROWSER_SEND_TO', function (event, sendToAll, webContentsId, channel, ...args) {
|
||||
let contents = webContents.fromId(webContentsId)
|
||||
if (!contents) {
|
||||
console.error(`Sending message to WebContents with unknown ID ${webContentsId}`)
|
||||
return
|
||||
}
|
||||
|
||||
contents.send(channel, ...args)
|
||||
if (sendToAll) {
|
||||
contents.sendToAll(channel, ...args)
|
||||
} else {
|
||||
contents.send(channel, ...args)
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue