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 54 of file HttpServer.h.

Constructor & Destructor Documentation

◆ HttpServer()

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

Definition at line 83 of file HttpServer.cpp.

84  {

References FIX::IntConvertor::convert().

Member Function Documentation

◆ onConfigure()

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

Definition at line 86 of file HttpServer.cpp.

90 {

◆ onConnect()

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

Implements FIX::SocketServer::Strategy.

Definition at line 152 of file HttpServer.cpp.

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

◆ onData()

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

Implements FIX::SocketServer::Strategy.

Definition at line 164 of file HttpServer.cpp.

◆ onDisconnect()

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

Implements FIX::SocketServer::Strategy.

Definition at line 169 of file HttpServer.cpp.

◆ onError()

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

Implements FIX::SocketServer::Strategy.

Definition at line 173 of file HttpServer.cpp.

◆ onInitialize()

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

Definition at line 92 of file HttpServer.cpp.

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

◆ onPoll()

bool FIX::HttpServer::onPoll ( )
private

Definition at line 139 of file HttpServer.cpp.

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

◆ onStart()

void FIX::HttpServer::onStart ( )
private

Definition at line 127 of file HttpServer.cpp.

132 {
133 }
134 
135 void HttpServer::onConnect( SocketServer& server, int a, int s )
136 {
137  if ( !socket_isValid( s ) ) return;

◆ onStop()

void FIX::HttpServer::onStop ( )
private

Definition at line 148 of file HttpServer.cpp.

148 {
149  return true;
150 }

◆ onTimeout()

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

Reimplemented from FIX::SocketServer::Strategy.

Definition at line 175 of file HttpServer.cpp.

◆ onWrite()

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

Implements FIX::SocketServer::Strategy.

Definition at line 160 of file HttpServer.cpp.

163 {

◆ start()

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

Definition at line 106 of file HttpServer.cpp.

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

◆ startGlobal()

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

Definition at line 54 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 ) {}
68 

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

◆ startThread()

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

Definition at line 179 of file HttpServer.cpp.

◆ stop()

void FIX::HttpServer::stop ( )

Definition at line 116 of file HttpServer.cpp.

123 {
124  if( !m_pServer || m_stop )
125  return false;

Referenced by startGlobal().

◆ stopGlobal()

void FIX::HttpServer::stopGlobal ( )
static

Definition at line 70 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 );
81  m_pServer->add( m_port, true, false, 0, 0 );

References FIX::HTTP_ACCEPT_PORT.

Member Data Documentation

◆ m_port

int FIX::HttpServer::m_port
private

Definition at line 102 of file HttpServer.h.

◆ m_pServer

SocketServer* FIX::HttpServer::m_pServer
private

Definition at line 99 of file HttpServer.h.

◆ m_settings

SessionSettings FIX::HttpServer::m_settings
private

Definition at line 100 of file HttpServer.h.

◆ m_stop

bool FIX::HttpServer::m_stop
private

Definition at line 103 of file HttpServer.h.

◆ m_threadid

thread_id FIX::HttpServer::m_threadid
private

Definition at line 101 of file HttpServer.h.

◆ s_count

int FIX::HttpServer::s_count = 0
staticprivate

Definition at line 106 of file HttpServer.h.

Referenced by startGlobal().

◆ s_mutex

Mutex FIX::HttpServer::s_mutex
staticprivate

Definition at line 105 of file HttpServer.h.

Referenced by startGlobal().

◆ s_pServer

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

Definition at line 107 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:103
FIX::HttpServer::onWrite
void onWrite(SocketServer &, int)
Definition: HttpServer.cpp:160
FIX::HttpServer::onInitialize
void onInitialize(const SessionSettings &)
Definition: HttpServer.cpp:92
FIX::SocketServer::block
bool block(Strategy &strategy, bool poll=0, double timeout=0.0)
Definition: SocketServer.cpp:165
FIX::HttpServer::s_pServer
static HttpServer * s_pServer
Definition: HttpServer.h:107
FIX::HttpServer::onConnect
void onConnect(SocketServer &, int, int)
Definition: HttpServer.cpp:152
FIX::HttpServer::m_settings
SessionSettings m_settings
Definition: HttpServer.h:100
FIX::socket_isValid
bool socket_isValid(int socket)
Definition: Utility.cpp:294
FIX::SocketServer::getMonitor
SocketMonitor & getMonitor()
Definition: SocketServer.h:87
FIX::HttpServer::s_count
static int s_count
Definition: HttpServer.h:106
FIX::HttpServer::onError
void onError(SocketServer &)
Definition: HttpServer.cpp:173
FIX::HttpServer::m_port
int m_port
Definition: HttpServer.h:102
FIX::HttpServer::HttpServer
HttpServer(const SessionSettings &)
Definition: HttpServer.cpp:83
FIX::SocketMonitor::drop
bool drop(int socket)
Definition: SocketMonitor.cpp:115
FIX::HttpServer::onTimeout
void onTimeout(SocketServer &)
Definition: HttpServer.cpp:175
FIX::HttpServer::s_mutex
static Mutex s_mutex
Definition: HttpServer.h:105
FIX::HttpServer::m_threadid
thread_id m_threadid
Definition: HttpServer.h:101
FIX::HttpServer::onStop
void onStop()
Definition: HttpServer.cpp:148
FIX::HttpServer::m_pServer
SocketServer * m_pServer
Definition: HttpServer.h:99
FIX::HTTP_ACCEPT_PORT
const char HTTP_ACCEPT_PORT[]
Definition: SessionSettings.h:148
FIX::SocketServer::add
int add(int port, bool reuse=false, bool noDelay=false, int sendBufSize=0, int rcvBufSize=0)
Definition: SocketServer.cpp:114
FIX::HttpServer::stop
void stop()
Definition: HttpServer.cpp:116

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