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.

107 lines
4.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2016 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of the ISC license
  6. http://www.isc.org/downloads/software-support-policy/isc-license/
  7. Permission to use, copy, modify, and/or distribute this software for any
  8. purpose with or without fee is hereby granted, provided that the above
  9. copyright notice and this permission notice appear in all copies.
  10. THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD
  11. TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  12. FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
  13. OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  14. USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  16. OF THIS SOFTWARE.
  17. -----------------------------------------------------------------------------
  18. To release a closed-source product which uses other parts of JUCE not
  19. licensed under the ISC terms, commercial licenses are available: visit
  20. www.juce.com for more information.
  21. ==============================================================================
  22. */
  23. #ifndef JUCE_INTERPROCESSCONNECTIONSERVER_H_INCLUDED
  24. #define JUCE_INTERPROCESSCONNECTIONSERVER_H_INCLUDED
  25. //==============================================================================
  26. /**
  27. An object that waits for client sockets to connect to a port on this host, and
  28. creates InterprocessConnection objects for each one.
  29. To use this, create a class derived from it which implements the createConnectionObject()
  30. method, so that it creates suitable connection objects for each client that tries
  31. to connect.
  32. @see InterprocessConnection
  33. */
  34. class JUCE_API InterprocessConnectionServer : private Thread
  35. {
  36. public:
  37. //==============================================================================
  38. /** Creates an uninitialised server object.
  39. */
  40. InterprocessConnectionServer();
  41. /** Destructor. */
  42. ~InterprocessConnectionServer();
  43. //==============================================================================
  44. /** Starts an internal thread which listens on the given port number.
  45. While this is running, in another process tries to connect with the
  46. InterprocessConnection::connectToSocket() method, this object will call
  47. createConnectionObject() to create a connection to that client.
  48. Use stop() to stop the thread running.
  49. @param portNumber The port on which the server will receive
  50. connections
  51. @param bindAddress The address on which the server will listen
  52. for connections. An empty string indicates
  53. that it should listen on all addresses
  54. assigned to this machine.
  55. @see createConnectionObject, stop
  56. */
  57. bool beginWaitingForSocket (int portNumber, const String& bindAddress = String());
  58. /** Terminates the listener thread, if it's active.
  59. @see beginWaitingForSocket
  60. */
  61. void stop();
  62. protected:
  63. /** Creates a suitable connection object for a client process that wants to
  64. connect to this one.
  65. This will be called by the listener thread when a client process tries
  66. to connect, and must return a new InterprocessConnection object that will
  67. then run as this end of the connection.
  68. @see InterprocessConnection
  69. */
  70. virtual InterprocessConnection* createConnectionObject() = 0;
  71. private:
  72. //==============================================================================
  73. ScopedPointer<StreamingSocket> socket;
  74. void run() override;
  75. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (InterprocessConnectionServer)
  76. };
  77. #endif // JUCE_INTERPROCESSCONNECTIONSERVER_H_INCLUDED