Index Source Files Annotated Class List Alphabetical Class List Class Hierarchy Graphical Class Hierarchy

# HttpServer.h

Go to the documentation of this file.

    00001 /* -*- C++ -*- */
    00002
    00003 /****************************************************************************
    00004 ** Copyright (c) quickfixengine.org  All rights reserved.
    00005 **
    00006 ** This file is part of the QuickFIX FIX Engine
    00007 **
    00008 ** This file may be distributed under the terms of the quickfixengine.org
    00009 ** license as defined by quickfixengine.org and appearing in the file
    00010 ** LICENSE included in the packaging of this file.
    00011 **
    00012 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
    00013 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
    00014 **
    00015 ** See http://www.quickfixengine.org/LICENSE for licensing information.
    00016 **
    00017 ** Contact ask@quickfixengine.org if any conditions of this licensing are
    00018 ** not clear to you.
    00019 **
    00020 ****************************************************************************/
    00021
    00022 #ifndef FIX_HTTPSERVER_H
    00023 #define FIX_HTTPSERVER_H
    00024
    00025 #ifdef _MSC_VER
    00026 #pragma warning( disable : 4503 4355 4786 4290 )
    00027 #endif
    00028
    00029 #include "SocketServer.h"
    00030 #include "SessionSettings.h"
    00031 #include "Exceptions.h"
    00032 #include "Mutex.h"
    00033
    00034 namespace FIX
    00035 {
    00037 class HttpServer : public SocketServer::Strategy
    00038 {
    00039 public:
    00040   HttpServer( const SessionSettings& ) throw( ConfigError );
    00041
    00042   static void startGlobal( const SessionSettings& ) throw ( ConfigError, RuntimeError );
    00043   static void stopGlobal();
    00044
    00045   void start() throw ( ConfigError, RuntimeError );
    00046   void stop();
    00047
    00048 private:
    00049   void onConfigure( const SessionSettings& ) throw ( ConfigError );
    00050   void onInitialize( const SessionSettings& ) throw ( RuntimeError );
    00051
    00052   void onStart();
    00053   bool onPoll();
    00054   void onStop();
    00055
    00056   void onConnect( SocketServer&, int, int );
    00057   void onWrite( SocketServer&, int );
    00058   bool onData( SocketServer&, int );
    00059   void onDisconnect( SocketServer&, int );
    00060   void onError( SocketServer& );
    00061   void onTimeout( SocketServer& );
    00062
    00063   static THREAD_PROC startThread( void* p );
    00064
    00065   SocketServer* m_pServer;
    00066   SessionSettings m_settings;
    00067   thread_id m_threadid;
    00068   int m_port;
    00069   bool m_stop;
    00070
    00071   static Mutex s_mutex;
    00072   static int s_count;
    00073   static HttpServer* s_pServer;
    00074 };
    00076 }
    00077
    00078 #endif //FIX_HTTPSERVER_H