JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_InterprocessConnection.h
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23namespace juce
24{
25
26class InterprocessConnectionServer;
27class MemoryBlock;
28
29
30//==============================================================================
54{
55public:
56 //==============================================================================
73 InterprocessConnection (bool callbacksOnMessageThread = true,
74 uint32 magicMessageHeaderNumber = 0xf2b49e2c);
75
78
79 //==============================================================================
91 bool connectToSocket (const String& hostName,
92 int portNumber,
93 int timeOutMillisecs);
94
107 bool connectToPipe (const String& pipeName, int pipeReceiveMessageTimeoutMs);
108
121 bool createPipe (const String& pipeName, int pipeReceiveMessageTimeoutMs, bool mustNotExist = false);
122
124 enum class Notify { no, yes };
125
134 void disconnect (int timeoutMs = -1, Notify notify = Notify::yes);
135
137 bool isConnected() const;
138
140 StreamingSocket* getSocket() const noexcept { return socket.get(); }
141
143 NamedPipe* getPipe() const noexcept { return pipe.get(); }
144
148 String getConnectedHostName() const;
149
150 //==============================================================================
159 bool sendMessage (const MemoryBlock& message);
160
161 //==============================================================================
168 virtual void connectionMade() = 0;
169
176 virtual void connectionLost() = 0;
177
189 virtual void messageReceived (const MemoryBlock& message) = 0;
190
191
192private:
193 //==============================================================================
194 ReadWriteLock pipeAndSocketLock;
197 bool callbackConnectionState = false;
198 const bool useMessageThread;
199 const uint32 magicMessageHeader;
200 int pipeReceiveMessageTimeout = -1;
201
202 friend class InterprocessConnectionServer;
203 void initialise();
204 void initialiseWithSocket (std::unique_ptr<StreamingSocket>);
205 void initialiseWithPipe (std::unique_ptr<NamedPipe>);
206 void deletePipeAndSocket();
207 void connectionMadeInt();
208 void connectionLostInt();
209 void deliverDataInt (const MemoryBlock&);
210 bool readNextMessage();
211 int readData (void*, int);
212
213 struct ConnectionThread;
215 std::atomic<bool> threadIsRunning { false };
216
217 class SafeAction;
219
220 void runThread();
221 int writeData (void*, int);
222
224};
225
226} // namespace juce
An object that waits for client sockets to connect to a port on this host, and creates InterprocessCo...
Manages a simple two-way messaging connection to another process, using either a socket or a named pi...
virtual void connectionMade()=0
Called when the connection is first connected.
virtual void messageReceived(const MemoryBlock &message)=0
Called when a message arrives.
StreamingSocket * getSocket() const noexcept
Returns the socket that this connection is using (or nullptr if it uses a pipe).
Notify
Whether the disconnect call should trigger callbacks.
virtual void connectionLost()=0
Called when the connection is broken.
NamedPipe * getPipe() const noexcept
Returns the pipe that this connection is using (or nullptr if it uses a socket).
A class to hold a resizable block of raw data.
A cross-process pipe that can have data written to and read from it.
A critical section that allows multiple simultaneous readers.
A wrapper for a streaming (TCP) socket.
Definition juce_Socket.h:82
The JUCE String class!
Definition juce_String.h:53
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
This is a shorthand way of writing both a JUCE_DECLARE_NON_COPYABLE and JUCE_LEAK_DETECTOR macro for ...
JUCE Namespace.
unsigned int uint32
A platform-independent 32-bit unsigned integer type.
pipe
socket