AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
ACSoap.h File Reference
#include "Define.h"
#include <future>
#include <memory>

Go to the source code of this file.

Classes

class  SOAPCommand
 

Functions

void process_message (struct soap *soap_message)
 
void ACSoapThread (const std::string &host, uint16 port)
 

Function Documentation

◆ ACSoapThread()

void ACSoapThread ( const std::string &  host,
uint16  port 
)
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
38 // allow rebinding while the previous socket is still in TIME_WAIT (e.g. on a quick restart)
39 soap.bind_flags = SO_REUSEADDR;
40
41 if (!soap_valid_socket(soap_bind(&soap, host.c_str(), port, 100)))
42 {
43 LOG_ERROR("network.soap", "ACSoap: couldn't bind to {}:{}", host, port);
44 // graceful shutdown: exit() here would destroy SocketMgr before StopNetwork() and assert
46 return;
47 }
48
49 LOG_INFO("network.soap", "ACSoap: bound to http://{}:{}", host, port);
50
51 while (!World::IsStopped())
52 {
53 if (!soap_valid_socket(soap_accept(&soap)))
54 continue; // ran into an accept timeout
55
56 LOG_DEBUG("network.soap", "ACSoap: accepted connection from IP={}.{}.{}.{}", (int)(soap.ip >> 24) & 0xFF, (int)(soap.ip >> 16) & 0xFF, (int)(soap.ip >> 8) & 0xFF, (int)soap.ip & 0xFF);
57 struct soap* thread_soap = soap_copy(&soap);// make a safe copy
58
59 process_message(thread_soap);
60 }
61
62 soap_destroy(&soap);
63 soap_end(&soap);
64 soap_done(&soap);
65}
void process_message(struct soap *soap_message)
Definition ACSoap.cpp:67
#define LOG_INFO(filterType__,...)
Definition Log.h:153
#define LOG_ERROR(filterType__,...)
Definition Log.h:145
#define LOG_DEBUG(filterType__,...)
Definition Log.h:157
static void StopNow(uint8 exitcode)
Definition World.h:188
static bool IsStopped()
Definition World.h:189
@ ERROR_EXIT_CODE
Definition World.h:54

References ERROR_EXIT_CODE, World::IsStopped(), LOG_DEBUG, LOG_ERROR, LOG_INFO, process_message(), and World::StopNow().

Referenced by main().

◆ process_message()

void process_message ( struct soap *  soap_message)
68{
69 LOG_TRACE("network.soap", "SOAPWorkingThread::process_message");
70
71 soap_serve(soap_message);
72 soap_destroy(soap_message); // dealloc C++ data
73 soap_end(soap_message); // dealloc data and clean up
74 soap_free(soap_message); // detach soap struct and fre up the memory
75}
#define LOG_TRACE(filterType__,...)
Definition Log.h:161

References LOG_TRACE.

Referenced by ACSoapThread().