Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

juce_InterprocessConnectionServer.h 3.2KB

9 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCE_INTERPROCESSCONNECTIONSERVER_H_INCLUDED
  18. #define JUCE_INTERPROCESSCONNECTIONSERVER_H_INCLUDED
  19. //==============================================================================
  20. /**
  21. An object that waits for client sockets to connect to a port on this host, and
  22. creates InterprocessConnection objects for each one.
  23. To use this, create a class derived from it which implements the createConnectionObject()
  24. method, so that it creates suitable connection objects for each client that tries
  25. to connect.
  26. @see InterprocessConnection
  27. */
  28. class JUCE_API InterprocessConnectionServer : private Thread
  29. {
  30. public:
  31. //==============================================================================
  32. /** Creates an uninitialised server object.
  33. */
  34. InterprocessConnectionServer();
  35. /** Destructor. */
  36. ~InterprocessConnectionServer();
  37. //==============================================================================
  38. /** Starts an internal thread which listens on the given port number.
  39. While this is running, in another process tries to connect with the
  40. InterprocessConnection::connectToSocket() method, this object will call
  41. createConnectionObject() to create a connection to that client.
  42. Use stop() to stop the thread running.
  43. @see createConnectionObject, stop
  44. */
  45. bool beginWaitingForSocket (int portNumber);
  46. /** Terminates the listener thread, if it's active.
  47. @see beginWaitingForSocket
  48. */
  49. void stop();
  50. protected:
  51. /** Creates a suitable connection object for a client process that wants to
  52. connect to this one.
  53. This will be called by the listener thread when a client process tries
  54. to connect, and must return a new InterprocessConnection object that will
  55. then run as this end of the connection.
  56. @see InterprocessConnection
  57. */
  58. virtual InterprocessConnection* createConnectionObject() = 0;
  59. private:
  60. //==============================================================================
  61. ScopedPointer <StreamingSocket> socket;
  62. void run() override;
  63. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (InterprocessConnectionServer)
  64. };
  65. #endif // JUCE_INTERPROCESSCONNECTIONSERVER_H_INCLUDED