The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

97 lines
3.5KB

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