-
Notifications
You must be signed in to change notification settings - Fork 11
Using IPC (Inter Process Communication)
Electron applications are divided into two parts: the main process and the renderer process(es).
The renderer processes run our BrowserWindow
s, i.e. our client code (HTML, CSS and client JavaScript).
Renderer processes do not have access to Node.js APIs, but can run JavaScript just like any other real browser, and can fetch data from external APIs, for example.
The launcher client code is contained in the src/fsolauncher_ui
folder, mainly in the src/fsolauncher_ui/client.js
file.
The main process, however, does have access to Node.js, and is essentially the Node.js backend for these renderer processes. All filesystem operations and anything needing Node.js APIs (and Node.js module dependencies) will be done here.
The launcher main code starts in main.js
, and the rest is in the src/fsolauncher
folder.
Renderer and main processes communicate with each other using IPC (Inter-process Communication), with JavaScript object payloads.
- In the launcher’s main process, the
src/fsolauncher/library/ipc-bridge.js
file is used to send messages to the renderer (client). - In the launcher’s renderer process (client.js), the
onMessage
function is used to receive these messages.
- In the launcher’s renderer process (client.js), the
sendToMain
function is used to send messages to the main process. - In the launcher’s main process, the
src/fsolauncher/event-handlers.js
file is used to receive these messages.
Home · User docs · Developer docs · FAQ