OpenShot Audio Library | OpenShotAudio: juce::ChildProcessSlave Class Reference

OpenShot Audio Library | OpenShotAudio 0.3.2

Loading...
Searching...
No Matches
Public Member Functions | List of all members
juce::ChildProcessSlave Class Referenceabstract

`#include <juce_ConnectedChildProcess.h>`

## Public Member Functions
| ChildProcessSlave ()
virtual | ~ChildProcessSlave ()
bool | initialiseFromCommandLine (const String &commandLine, const String &commandLineUniqueID, int timeoutMs=0)
virtual void | handleMessageFromMaster (const MemoryBlock &)=0
virtual void | handleConnectionMade ()
virtual void | handleConnectionLost ()
bool | sendMessageToMaster (const MemoryBlock &)

## Detailed Description

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

Definition at line 47 of file juce_ConnectedChildProcess.h.

## Constructor & Destructor Documentation

## ◆ ChildProcessSlave()

juce::ChildProcessSlave::ChildProcessSlave | ( |  | ) |

Creates a non-connected slave process. Use initialiseFromCommandLine to connect to a master process.

Definition at line 229 of file juce_ConnectedChildProcess.cpp.

## ◆ ~ChildProcessSlave()

juce::ChildProcessSlave::~ChildProcessSlave | ( |  | ) |
| virtual

Destructor.

Definition at line 230 of file juce_ConnectedChildProcess.cpp.

## Member Function Documentation

## ◆ handleConnectionLost()

void juce::ChildProcessSlave::handleConnectionLost | ( |  | ) |
| virtual

This will be called when the connection to the master process is lost. The call may be made from any thread (including the message thread). Typically, if your process only exists to act as a slave, you should probably exit when this happens.

Definition at line 233 of file juce_ConnectedChildProcess.cpp.

## ◆ handleConnectionMade()

void juce::ChildProcessSlave::handleConnectionMade | ( |  | ) |
| virtual

This will be called when the master process finishes connecting to this slave. The call will probably be made on a background thread, so be careful with your thread-safety!

Definition at line 232 of file juce_ConnectedChildProcess.cpp.

## ◆ handleMessageFromMaster()

virtual void juce::ChildProcessSlave::handleMessageFromMaster | ( | const MemoryBlock & |  | ) |
| pure virtual

This will be called to deliver messages from the master process. The call will probably be made on a background thread, so be careful with your thread-safety! You may want to respond by sending back a message with sendMessageToMaster()

## ◆ initialiseFromCommandLine()

bool juce::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.

Definition at line 244 of file juce_ConnectedChildProcess.cpp.

## ◆ sendMessageToMaster()

bool juce::ChildProcessSlave::sendMessageToMaster | ( | const MemoryBlock & | mb | ) |

Tries to send a message to the master process. This returns true if the message was sent, but doesn't check that it actually gets delivered at the other end. If successful, the data will emerge in a call to your ChildProcessMaster::handleMessageFromSlave().

Definition at line 235 of file juce_ConnectedChildProcess.cpp.

The documentation for this class was generated from the following files:

- juce_ConnectedChildProcess.h
- juce_ConnectedChildProcess.cpp