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.

101 lines
3.6KB

  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. @param portNumber The port on which the server will receive
  44. connections
  45. @param bindAddress The address on which the server will listen
  46. for connections. An empty string indicates
  47. that it should listen on all addresses
  48. assigned to this machine.
  49. @see createConnectionObject, stop
  50. */
  51. bool beginWaitingForSocket (int portNumber, const String& bindAddress = String());
  52. /** Terminates the listener thread, if it's active.
  53. @see beginWaitingForSocket
  54. */
  55. void stop();
  56. protected:
  57. /** Creates a suitable connection object for a client process that wants to
  58. connect to this one.
  59. This will be called by the listener thread when a client process tries
  60. to connect, and must return a new InterprocessConnection object that will
  61. then run as this end of the connection.
  62. @see InterprocessConnection
  63. */
  64. virtual InterprocessConnection* createConnectionObject() = 0;
  65. private:
  66. //==============================================================================
  67. ScopedPointer<StreamingSocket> socket;
  68. void run() override;
  69. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (InterprocessConnectionServer)
  70. };
  71. #endif // JUCE_INTERPROCESSCONNECTIONSERVER_H_INCLUDED