OregonCore  revision be9e804-git
Your Favourite TBC server
OCSoapRunnable Class Reference

#include <OCSoap.h>

+ Inheritance diagram for OCSoapRunnable:

Public Member Functions

 OCSoapRunnable ()
 
void run ()
 
void setListenArguments (std::string host, uint16 port)
 
- Public Member Functions inherited from ACE_Based::Runnable
virtual ~Runnable ()
 
void incReference ()
 
void decReference ()
 

Private Attributes

std::string m_host
 
uint16 m_port
 

Detailed Description

Definition at line 33 of file OCSoap.h.

Constructor & Destructor Documentation

OCSoapRunnable::OCSoapRunnable ( )
inline

Definition at line 36 of file OCSoap.h.

References run().

36 { }

Member Function Documentation

void OCSoapRunnable::run ( void  )
virtual

Implements ACE_Based::Runnable.

Definition at line 22 of file OCSoap.cpp.

References World::IsStopped(), m_host, m_port, POOL_SIZE, and sLog.

Referenced by OCSoapRunnable().

23 {
24  // create pool
25  SOAPWorkingThread pool;
26  pool.activate (THR_NEW_LWP | THR_JOINABLE, POOL_SIZE);
27 
28  struct soap soap;
29  soap_init(&soap);
30  soap_set_imode(&soap, SOAP_C_UTFSTRING);
31  soap_set_omode(&soap, SOAP_C_UTFSTRING);
32 
33  // check every 3 seconds if world ended
34  soap.accept_timeout = 3;
35  soap.recv_timeout = 5;
36  soap.send_timeout = 5;
37  if (soap_bind(&soap, m_host.c_str(), m_port, 100) < 0)
38  {
39  sLog.outError("OCSoap: couldn't bind to %s:%d", m_host.c_str(), m_port);
40  pool.msg_queue()->deactivate();
41  pool.wait();
42  soap_done(&soap);
43  return;
44  }
45 
46  sLog.outString("OCSoap: bound to http://%s:%d", m_host.c_str(), m_port);
47 
48  while (!World::IsStopped())
49  {
50  if (!soap_valid_socket(soap_accept(&soap)))
51  continue; // ran into an accept timeout
52 
53  sLog.outDebug("OCSoap: accepted connection from IP=%d.%d.%d.%d", (int)(soap.ip >> 24) & 0xFF, (int)(soap.ip >> 16) & 0xFF, (int)(soap.ip >> 8) & 0xFF, (int)soap.ip & 0xFF);
54  struct soap* thread_soap = soap_copy(&soap);// make a safe copy
55 
56  ACE_Message_Block* mb = new ACE_Message_Block(sizeof(struct soap*));
57  ACE_OS::memcpy (mb->wr_ptr(), &thread_soap, sizeof(struct soap*));
58  pool.putq(mb);
59  }
60 
61  pool.msg_queue()->deactivate();
62  pool.wait();
63 
64  soap_done(&soap);
65 }
uint16 m_port
Definition: OCSoap.h:45
std::string m_host
Definition: OCSoap.h:44
#define sLog
Log class singleton.
Definition: Log.h:187
static bool IsStopped()
Definition: World.h:638
#define POOL_SIZE
Definition: OCSoap.cpp:20
void OCSoapRunnable::setListenArguments ( std::string  host,
uint16  port 
)
inline

Definition at line 38 of file OCSoap.h.

References m_host, and m_port.

Referenced by Master::Run().

39  {
40  m_host = host;
41  m_port = port;
42  }
uint16 m_port
Definition: OCSoap.h:45
std::string m_host
Definition: OCSoap.h:44

Member Data Documentation

std::string OCSoapRunnable::m_host
private

Definition at line 44 of file OCSoap.h.

Referenced by run(), and setListenArguments().

uint16 OCSoapRunnable::m_port
private

Definition at line 45 of file OCSoap.h.

Referenced by run(), and setListenArguments().


The documentation for this class was generated from the following files: