Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
FIX::HttpServer Class Reference

Basic HTTP Server. More...

#include <HttpServer.h>

Inheritance diagram for FIX::HttpServer:
Inheritance graph
[legend]
Collaboration diagram for FIX::HttpServer:
Collaboration graph
[legend]

Public Member Functions

 HttpServer (const SessionSettings &) throw ( ConfigError )
 
void start () throw ( ConfigError, RuntimeError )
 
void stop ()
 
- Public Member Functions inherited from FIX::SocketServer::Strategy
virtual ~Strategy ()
 

Static Public Member Functions

static void startGlobal (const SessionSettings &) throw ( ConfigError, RuntimeError )
 
static void stopGlobal ()
 

Private Member Functions

void onConfigure (const SessionSettings &) throw ( ConfigError )
 
void onInitialize (const SessionSettings &) throw ( RuntimeError )
 
void onStart ()
 
bool onPoll ()
 
void onStop ()
 
void onConnect (SocketServer &, int, int)
 
void onWrite (SocketServer &, int)
 
bool onData (SocketServer &, int)
 
void onDisconnect (SocketServer &, int)
 
void onError (SocketServer &)
 
void onTimeout (SocketServer &)
 

Static Private Member Functions

static THREAD_PROC startThread (void *p)
 

Private Attributes

SocketServerm_pServer
 
SessionSettings m_settings
 
thread_id m_threadid
 
int m_port
 
bool m_stop
 

Static Private Attributes

static Mutex s_mutex
 
static int s_count = 0
 
static HttpServers_pServer = 0
 

Detailed Description

Basic HTTP Server.

Definition at line 52 of file HttpServer.h.

Constructor & Destructor Documentation

◆ HttpServer()

FIX::HttpServer::HttpServer ( const SessionSettings settings)
throw (ConfigError
)

Definition at line 82 of file HttpServer.cpp.

84  {

Member Function Documentation

◆ onConfigure()

void FIX::HttpServer::onConfigure ( const SessionSettings s)
throw (ConfigError
)
private

Definition at line 85 of file HttpServer.cpp.

90 {

◆ onConnect()

void FIX::HttpServer::onConnect ( SocketServer server,
int  a,
int  s 
)
privatevirtual

Implements FIX::SocketServer::Strategy.

Definition at line 151 of file HttpServer.cpp.

153 {
154 }
155 
156 void HttpServer::onError( SocketServer& ) {}
157 

◆ onData()

bool FIX::HttpServer::onData ( SocketServer server,
int  s 
)
privatevirtual

Implements FIX::SocketServer::Strategy.

Definition at line 163 of file HttpServer.cpp.

163 {
164  HttpServer * pServer = static_cast < HttpServer* > ( p );
165  pServer->onStart();
166  return 0;

References onStart().

◆ onDisconnect()

void FIX::HttpServer::onDisconnect ( SocketServer ,
int  s 
)
privatevirtual

Implements FIX::SocketServer::Strategy.

Definition at line 168 of file HttpServer.cpp.

◆ onError()

void FIX::HttpServer::onError ( SocketServer )
privatevirtual

Implements FIX::SocketServer::Strategy.

Definition at line 172 of file HttpServer.cpp.

◆ onInitialize()

void FIX::HttpServer::onInitialize ( const SessionSettings s)
throw (RuntimeError
)
private

Definition at line 91 of file HttpServer.cpp.

100 {
101  if( m_stop ) return;
102  m_stop = true;
103  onStop();

◆ onPoll()

bool FIX::HttpServer::onPoll ( )
private

Definition at line 138 of file HttpServer.cpp.

139  {}
140  m_pServer->getMonitor().drop( s );
141 }
142 
143 void HttpServer::onWrite( SocketServer& server, int s )
144 {
145 }

◆ onStart()

void FIX::HttpServer::onStart ( )
private

Definition at line 126 of file HttpServer.cpp.

132 {
133 }
134 
135 void HttpServer::onConnect( SocketServer& server, int a, int s )
136 {

Referenced by onData().

◆ onStop()

void FIX::HttpServer::onStop ( )
private

Definition at line 147 of file HttpServer.cpp.

148 {
149  return true;

◆ onTimeout()

void FIX::HttpServer::onTimeout ( SocketServer )
privatevirtual

Reimplemented from FIX::SocketServer::Strategy.

Definition at line 174 of file HttpServer.cpp.

◆ onWrite()

void FIX::HttpServer::onWrite ( SocketServer server,
int  s 
)
privatevirtual

Implements FIX::SocketServer::Strategy.

Definition at line 159 of file HttpServer.cpp.

159 {
160 }
161 

◆ start()

void FIX::HttpServer::start ( )
throw ( ConfigError,
RuntimeError
)

Definition at line 105 of file HttpServer.cpp.

111 {
112  while ( !m_stop && m_pServer && m_pServer->block( *this ) ) {}
113 

◆ startGlobal()

void FIX::HttpServer::startGlobal ( const SessionSettings s)
throw ( ConfigError,
RuntimeError
)
static

Definition at line 53 of file HttpServer.cpp.

54 {
55  Locker l( s_mutex );
56 
57  s_count -= 1;
58  if( !s_count && s_pServer )
59  {
60  s_pServer->stop();
61  delete s_pServer;
62  s_pServer = 0;
63  }
64 }
65 
66 HttpServer::HttpServer( const SessionSettings& settings ) throw( ConfigError )
67 : m_pServer( 0 ), m_settings( settings ), m_threadid( 0 ), m_port( 0 ), m_stop( false ) {}

References s_count, s_mutex, s_pServer, and stop().

◆ startThread()

THREAD_PROC FIX::HttpServer::startThread ( void *  p)
staticprivate

Definition at line 178 of file HttpServer.cpp.

◆ stop()

void FIX::HttpServer::stop ( )

Definition at line 115 of file HttpServer.cpp.

123 {
124  if( !m_pServer || m_stop )

Referenced by startGlobal().

◆ stopGlobal()

void FIX::HttpServer::stopGlobal ( )
static

Definition at line 69 of file HttpServer.cpp.

71 {
72  m_port = s.get().getInt( HTTP_ACCEPT_PORT );
73 }
74 
75 void HttpServer::onInitialize( const SessionSettings& s )
76 throw ( RuntimeError )
77 {
78  try
79  {
80  m_pServer = new SocketServer( 1 );

References FIX::HTTP_ACCEPT_PORT.

Member Data Documentation

◆ m_port

int FIX::HttpServer::m_port
private

Definition at line 99 of file HttpServer.h.

◆ m_pServer

SocketServer* FIX::HttpServer::m_pServer
private

Definition at line 96 of file HttpServer.h.

◆ m_settings

SessionSettings FIX::HttpServer::m_settings
private

Definition at line 97 of file HttpServer.h.

◆ m_stop

bool FIX::HttpServer::m_stop
private

Definition at line 100 of file HttpServer.h.

◆ m_threadid

thread_id FIX::HttpServer::m_threadid
private

Definition at line 98 of file HttpServer.h.

◆ s_count

int FIX::HttpServer::s_count = 0
staticprivate

Definition at line 103 of file HttpServer.h.

Referenced by startGlobal().

◆ s_mutex

Mutex FIX::HttpServer::s_mutex
staticprivate

Definition at line 102 of file HttpServer.h.

Referenced by startGlobal().

◆ s_pServer

HttpServer * FIX::HttpServer::s_pServer = 0
staticprivate

Definition at line 104 of file HttpServer.h.

Referenced by startGlobal().


The documentation for this class was generated from the following files:
FIX::HttpServer::m_stop
bool m_stop
Definition: HttpServer.h:100
FIX::HttpServer::onWrite
void onWrite(SocketServer &, int)
Definition: HttpServer.cpp:159
FIX::HttpServer::onInitialize
void onInitialize(const SessionSettings &)
Definition: HttpServer.cpp:91
FIX::SocketServer::block
bool block(Strategy &strategy, bool poll=0, double timeout=0.0)
Definition: SocketServer.cpp:163
FIX::HttpServer::s_pServer
static HttpServer * s_pServer
Definition: HttpServer.h:104
FIX::HttpServer::onConnect
void onConnect(SocketServer &, int, int)
Definition: HttpServer.cpp:151
FIX::HttpServer::m_settings
SessionSettings m_settings
Definition: HttpServer.h:97
FIX::SocketServer::getMonitor
SocketMonitor & getMonitor()
Definition: SocketServer.h:85
FIX::HttpServer::s_count
static int s_count
Definition: HttpServer.h:103
FIX::HttpServer::onError
void onError(SocketServer &)
Definition: HttpServer.cpp:172
FIX::HttpServer::m_port
int m_port
Definition: HttpServer.h:99
FIX::HttpServer::HttpServer
HttpServer(const SessionSettings &)
Definition: HttpServer.cpp:82
FIX::SocketMonitor::drop
bool drop(int socket)
Definition: SocketMonitor.cpp:113
FIX::HttpServer::s_mutex
static Mutex s_mutex
Definition: HttpServer.h:102
FIX::HttpServer::m_threadid
thread_id m_threadid
Definition: HttpServer.h:98
FIX::HttpServer::onStop
void onStop()
Definition: HttpServer.cpp:147
FIX::HttpServer::m_pServer
SocketServer * m_pServer
Definition: HttpServer.h:96
FIX::HTTP_ACCEPT_PORT
const char HTTP_ACCEPT_PORT[]
Definition: SessionSettings.h:146
FIX::HttpServer::stop
void stop()
Definition: HttpServer.cpp:115

Generated on Wed Apr 29 2020 19:41:30 for QuickFIX by doxygen 1.8.16 written by Dimitri van Heesch, © 1997-2001