openshot-audio  0.1.2
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) 2015 - ROLI Ltd.
6 
7  Permission is granted to use this software under the terms of either:
8  a) the GPL v2 (or any later version)
9  b) the Affero GPL v3
10 
11  Details of these licenses can be found at: www.gnu.org/licenses
12 
13  JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
14  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15  A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 
17  ------------------------------------------------------------------------------
18 
19  To release a closed-source product which uses JUCE, commercial licenses are
20  available: visit www.juce.com for more information.
21 
22  ==============================================================================
23 */
24 
25 #ifndef JUCE_INTERPROCESSCONNECTION_H_INCLUDED
26 #define JUCE_INTERPROCESSCONNECTION_H_INCLUDED
27 
29 class MemoryBlock;
30 
31 
32 //==============================================================================
51 {
52 public:
53  //==============================================================================
70  InterprocessConnection (bool callbacksOnMessageThread = true,
71  uint32 magicMessageHeaderNumber = 0xf2b49e2c);
72 
74  virtual ~InterprocessConnection();
75 
76  //==============================================================================
88  bool connectToSocket (const String& hostName,
89  int portNumber,
90  int timeOutMillisecs);
91 
104  bool connectToPipe (const String& pipeName, int pipeReceiveMessageTimeoutMs);
105 
117  bool createPipe (const String& pipeName, int pipeReceiveMessageTimeoutMs);
118 
120  void disconnect();
121 
123  bool isConnected() const;
124 
126  StreamingSocket* getSocket() const noexcept { return socket; }
127 
129  NamedPipe* getPipe() const noexcept { return pipe; }
130 
134  String getConnectedHostName() const;
135 
136  //==============================================================================
145  bool sendMessage (const MemoryBlock& message);
146 
147  //==============================================================================
154  virtual void connectionMade() = 0;
155 
162  virtual void connectionLost() = 0;
163 
175  virtual void messageReceived (const MemoryBlock& message) = 0;
176 
177 
178 private:
179  //==============================================================================
182  CriticalSection pipeAndSocketLock;
185  bool callbackConnectionState;
186  const bool useMessageThread;
187  const uint32 magicMessageHeader;
188  int pipeReceiveMessageTimeout;
189 
191  void initialiseWithSocket (StreamingSocket*);
192  void initialiseWithPipe (NamedPipe*);
193  void deletePipeAndSocket();
194  void connectionMadeInt();
195  void connectionLostInt();
196  void deliverDataInt (const MemoryBlock&);
197  bool readNextMessageInt();
198 
200  friend struct ConnectionThread;
203  void runThread();
204  int writeData (void*, int);
205 
207 };
208 
209 #endif // JUCE_INTERPROCESSCONNECTION_H_INCLUDED
Definition: juce_InterprocessConnectionServer.h:40
Definition: juce_InterprocessConnection.cpp:25
Definition: juce_Socket.h:42
StreamingSocket * getSocket() const noexcept
Definition: juce_InterprocessConnection.h:126
#define noexcept
Definition: juce_CompilerSupport.h:141
Definition: juce_NamedPipe.h:41
Definition: juce_MemoryBlock.h:38
Definition: juce_String.h:43
#define JUCE_API
Definition: juce_StandardHeader.h:139
#define const
Definition: juce_CriticalSection.h:47
unsigned int uint32
Definition: juce_MathsFunctions.h:51
NamedPipe * getPipe() const noexcept
Definition: juce_InterprocessConnection.h:129
Definition: juce_WeakReference.h:82
Definition: juce_ContainerDeletePolicy.h:44
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition: juce_PlatformDefs.h:198
Definition: juce_InterprocessConnection.h:50