Acts as the slave end of a master/slave pair of connected processes.
The ChildProcessSlave and ChildProcessMaster classes make it easy for an app to spawn a child process, and to manage a 2-way messaging connection to control it.
To use the system, you need to create subclasses of both ChildProcessSlave and ChildProcessMaster. To instantiate the ChildProcessSlave object, you must add some code to your main() or JUCEApplication::initialise() function that calls the initialiseFromCommandLine() method to check the app's command-line parameters to see whether it's being launched as a child process. If this returns true then the slave process can be allowed to run, and its handleMessageFromMaster() method will be called whenever a message arrives.
The juce demo app has a good example of this class in action.
- See Also
- ChildProcessMaster, InterprocessConnection, ChildProcess
bool ChildProcessSlave::initialiseFromCommandLine |
( |
const String & |
commandLine, |
|
|
const String & |
commandLineUniqueID, |
|
|
int |
timeoutMs = 0 |
|
) |
| |
This checks some command-line parameters to see whether they were generated by ChildProcessMaster::launchSlaveProcess(), and if so, connects to that master process.
In an exe that can be used as a child process, you should add some code to your main() or JUCEApplication::initialise() that calls this method.
The commandLineUniqueID should be a short alphanumeric identifier (no spaces!) that matches the string passed to ChildProcessMaster::launchSlaveProcess().
The timeoutMs parameter lets you specify how long the child process is allowed to run without receiving a ping from the master before the master is considered to have died, and handleConnectionLost() will be called. Passing <= 0 for this timeout makes it use a default value.
Returns true if the command-line matches and the connection is made successfully.