22#include <juce_events/juce_events.h>
24#include "cello_object.h"
25#include "cello_sync.h"
26#include "cello_value.h"
36struct IpcClientProperties :
public Object
38 IpcClientProperties (
const juce::String& name,
Object* state)
42 MAKE_VALUE_MEMBER (
bool, connected,
false);
43 MAKE_VALUE_MEMBER (
int, rxCount, 0);
44 MAKE_VALUE_MEMBER (
int, txCount, 0);
49class IpcClient :
public juce::InterprocessConnection,
50 public juce::ValueTreeSynchroniser,
58 fullUpdateOnConnect = 0x04
79 IpcClient (
Object& objectToWatch,
const juce::String& hostName,
int portNum,
int msTimeout, UpdateType updateType,
91 IpcClient (
Object& objectToWatch,
const juce::String& pipeName,
int msTimeout, UpdateType updateType,
118 IpcClient (
Object& objectToWatch, UpdateType updateType,
const juce::String& hostName,
int portNum,
119 const juce::String& pipeName,
int msTimeout,
Object* state =
nullptr);
121 void connectionMade ()
override;
122 void connectionLost ()
override;
129 void messageReceived (
const juce::MemoryBlock& message)
override;
138 void stateChanged (
const void* encodedChange,
size_t encodedSize)
override;
148 const juce::String host;
152 const juce::String pipe;
171struct IpcServerProperties :
public Object
173 IpcServerProperties (
const juce::String& path,
Object* state);
184 void startServer (
int portNum,
const juce::String& address = juce::String ());
209class IpcServer :
public juce::InterprocessConnectionServer
212 IpcServer (
Object& sync, IpcClient::UpdateType updateType,
const juce::String& statePath,
Object* state =
nullptr);
213 ~IpcServer ()
override;
223 bool startServer (
int portNumber,
const juce::String& bindAddress = juce::String ());
250 IpcClient::UpdateType update;
253 std::vector<std::unique_ptr<juce::InterprocessConnection>> connections;
Definition cello_ipc.h:52
IpcClient(Object &objectToWatch, const juce::String &hostName, int portNum, int msTimeout, UpdateType updateType, Object *state=nullptr)
Construct a new Ipc Client object that connects using sockets.
Definition cello_ipc.cpp:64
bool connect(ConnectOptions option=ConnectOptions::noOptions)
Attempt to make a connection to another IpcClient running in another process.
Definition cello_ipc.cpp:83
ConnectOptions
Definition cello_ipc.h:62
@ mustExist
pipe must already exist, fail if it doesn't
Definition cello_ipc.h:65
@ noOptions
default, used for sockets, which have no options.
Definition cello_ipc.h:63
@ createIfNeeded
If pipe exists, use it, otherwise create.
Definition cello_ipc.h:66
@ createOrFail
create the pipe, fail if we couldn't
Definition cello_ipc.h:64
Definition cello_ipc.h:210
bool startServer(int portNumber, const juce::String &bindAddress=juce::String())
Launch the thread that starts listening for incoming socket connections.
Definition cello_ipc.cpp:203
bool stopServer()
Stop the server.
Definition cello_ipc.cpp:223
juce::InterprocessConnection * createConnectionObject() override
When we get a connection, the base server class will call this so that we can create and return an in...
Definition cello_ipc.cpp:240
Definition cello_object.h:34
Object(const juce::String &type, const Object *state)
Construct a new cello::Object object, which will attempt to initialize from the 'state' parameter....
Definition cello_object.cpp:27
Properties struct to monitor an IPC client. Created automatically when creating an IpcClient object,...
Definition cello_ipc.h:37
Definition cello_ipc.h:172
MAKE_VALUE_MEMBER(bool, running, false)
will be updated whenever the server is started or stopped.
MAKE_VALUE_MEMBER(juce::String, bindAddress, {})
address to bind to, optional, see the JUCE docs
void stopServer()
Tell the server object we're controlling to stop.
Definition cello_ipc.cpp:166
MAKE_VALUE_MEMBER(int, portNumber, 0)
TCP port number to use (or in use, if we're running)
MAKE_VALUE_MEMBER(IpcServerStatus, status, IpcServerStatus::unknown)
will be updated with status info on an attempt to start/stop
void startServer(int portNum, const juce::String &address=juce::String())
Tell the server object we're controlling to start on the specified port (and optionally which address...
Definition cello_ipc.cpp:153