HttpServer.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* -*- C++ -*- */
  2. /****************************************************************************
  3. ** Copyright (c) 2001-2014
  4. **
  5. ** This file is part of the QuickFIX FIX Engine
  6. **
  7. ** This file may be distributed under the terms of the quickfixengine.org
  8. ** license as defined by quickfixengine.org and appearing in the file
  9. ** LICENSE included in the packaging of this file.
  10. **
  11. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  12. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  13. **
  14. ** See http://www.quickfixengine.org/LICENSE for licensing information.
  15. **
  16. ** Contact ask@quickfixengine.org if any conditions of this licensing are
  17. ** not clear to you.
  18. **
  19. ****************************************************************************/
  20. #ifndef FIX_HTTPSERVER_H
  21. #define FIX_HTTPSERVER_H
  22. #ifdef _MSC_VER
  23. #pragma warning( disable : 4503 4355 4786 4290 )
  24. #endif
  25. #include "SocketServer.h"
  26. #include "SessionSettings.h"
  27. #include "Exceptions.h"
  28. #include "Mutex.h"
  29. namespace FIX
  30. {
  31. /// Basic HTTP Server
  32. class HttpServer : public SocketServer::Strategy
  33. {
  34. public:
  35. HttpServer( const SessionSettings& ) throw( ConfigError );
  36. static void startGlobal( const SessionSettings& ) throw ( ConfigError, RuntimeError );
  37. static void stopGlobal();
  38. void start() throw ( ConfigError, RuntimeError );
  39. void stop();
  40. private:
  41. void onConfigure( const SessionSettings& ) throw ( ConfigError );
  42. void onInitialize( const SessionSettings& ) throw ( RuntimeError );
  43. void onStart();
  44. bool onPoll();
  45. void onStop();
  46. void onConnect( SocketServer&, int, int );
  47. void onWrite( SocketServer&, int );
  48. bool onData( SocketServer&, int );
  49. void onDisconnect( SocketServer&, int );
  50. void onError( SocketServer& );
  51. void onTimeout( SocketServer& );
  52. static THREAD_PROC startThread( void* p );
  53. SocketServer* m_pServer;
  54. SessionSettings m_settings;
  55. thread_id m_threadid;
  56. int m_port;
  57. bool m_stop;
  58. static Mutex s_mutex;
  59. static int s_count;
  60. static HttpServer* s_pServer;
  61. };
  62. /*! @} */
  63. }
  64. #endif //FIX_HTTPSERVER_H