TElectronIPCCommunication
Designtime |
Description
Below is a list of the most important properties, methods and events for TElectronIPCCommunication
. This component allows the communication between windows.
Properties for TElectronIPCCommunication
Property | Description |
---|---|
Channel: string | Sets the channel the IPCRenderer is going to listen to. If left blank, it listens to a default channel that is also used by TElectronBrowserWindow.SendMessage(AMessage: string) . |
Methods for TElectronIPCCommunication
Property | Description |
---|---|
Send(Channel: string; AMessage: JSValue) | Sends a message to the specified channel. |
Send(Channel: string; AMessage: string) | Sends a message to the specified channel. |
SendToParent(AMessage: JSValue) | Send a message to the parent window. |
Events for TElectronIPCCommunication
Property | Description |
---|---|
OnReceive | Triggers when a message has been received on the default channel. If the Channel property is set, then it triggers when a message arrives on that channel. |
Send message to parent
Sending a message to the parent window is as easy as dropping a TElectronIPCCommunication
onto the form and calling
TElectronBrowserWindow
.OnMessage
event will trigger when messages sent via the SendToParent
method are arriving.
Send message to a channel
It's possible to send a message to a defined channel. This way the communication is enabled between every window and not just parent-child windows.
A specific channel can be defined, but it's not required since every TElectronIPCCommunication
is listening to a default channel if no Channel
is given.
Sending a message to another form is as simple as calling:
When theChannel
property is defined, then the TElectronIPCCommunication
component is listening for messages that are arriving on that channel.
This allows further possibilites:
* Multiple messages can be distinguished: Multiple TElectronIPCCommunication
instances are dropped onto the form, and each of them are listening to a different channel.
* Multicast: On multiple forms the TElectronIPCCommunication
instances are listening for the same channel.
Receiving messages
Whenever a message has arrived to the channel that's being listened by the TElectronIPCCommunication
, the OnReceive
event triggers.
The message it receives is defined as TReceivedValue
. A message type check can be made before proceeding with the processing of the message:
String
, Boolean
, Integer
, Object (TJSObject)
, Array (TJSArray)
and Float
.