optsobjectexcludeSelfboolean - exclude send ipc message to main process when callingipcPlusM.sendToAll.
Ipc option used in ipcPlusM.sendToAll and ipcPlusM.sendToWins.
messagestring - Ipc message....args... - Whatever arguments the message needs.optionobject - You can indicate the last argument as an IPC option byipcPlusM.option({...}).
Send message with ...args to all opened window and to main process asynchronously.
NOTE
This is a broadcast method, it will not recieve callback.
messagestring - Ipc message....args... - Whatever arguments the message needs.optionobject - You can indicate the last argument as an IPC option byipcPlusM.option({...}).
Send message with ...args to all opened windows asynchronously. The renderer process can handle it by listening to the message through the electron.ipcRenderer or ipcPlus module.
NOTE
This is a broadcast method, it will not recieve callback.
Example:
Send IPC message (main process)
const ipcPlusM = require('electron-ipc-plus');
ipcPlusM.sendToWins('foobar:say-hello', 'Hello World!');Receive IPC message (renderer process)
<html>
<body>
<script>
const {ipcRenderer} = require('electron');
ipcRenderer.on('foobar:say-hello', (event, text) => {
console.log(text); // Prints "Hello World!"
});
</script>
</body>
</html>messagestring - Ipc message....args... - Whatever arguments the message needs.callbackfunction - You can specify a callback function to receive IPC reply at the last or the 2nd last argument.timeoutnumber - You can specify a timeout for the callback at the last argument. If no timeout specified, it will be 5000ms.
Returns number - If we have callback function, a session ID will returned.
Example:
Send IPC message (main process)
const ipcPlusM = require('electron-ipc-plus');
ipcPlusM.sendToMain('foobar:say-hello', (err, msg) => {
if ( err && err.code === 'ETIMEOUT' ) {
console.error('Timeout for ipc message foobar:say-hello');
return;
}
console.log(`foobar replied: ${msg}`);
});Receive and Reply IPC message (main process)
const {ipcMain} = require('electron');
ipcMain.on('foobar:say-hello', event => {
event.reply(null, 'Hi');
});winBrowserWindowmessagestring - Ipc message....args... - Whatever arguments the message needs.callbackfunction - You can specify a callback function to receive IPC reply at the last or the 2nd last argument.timeoutnumber - You can specify a timeout for the callback at the last argument. If no timeout specified, it will be 5000ms.
Returns number - If we have callback function, a session ID will returned.
Example:
Send IPC message (main process)
const ipcPlusM = require('electron-ipc-plus');
ipcPlusM.sendToMain('foobar:say-hello', (err, msg) => {
if ( err && err.code === 'ETIMEOUT' ) {
console.error('Timeout for ipc message foobar:say-hello');
return;
}
console.log(`foobar replied: ${msg}`);
});Receive and Reply IPC message (renderer process)
const {ipcRenderer} = require('electron');
ipcRenderer.on('foobar:say-hello', event => {
event.reply(null, 'Hi');
});sessionIdnumber - The session ID.
Cancel request sent to main or renderer process via ipcPlusM.sendToMain or ipcPlusM.sendToWin.
Turn on/off the debug information. No use in current version.