OregonCore  revision be9e804-git
Your Favourite TBC server
OCSoap.h
Go to the documentation of this file.
1 /*
2  * This file is part of the OregonCore Project. See AUTHORS file for Copyright information
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation; either version 2 of the License, or (at your
7  * option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <https://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef _OREGONSOAP_H
19 #define _OREGONSOAP_H
20 
21 #include "Common.h"
22 #include "World.h"
23 #include "AccountMgr.h"
24 #include "Log.h"
25 
26 #include "soapH.h"
27 #include "soapStub.h"
28 
29 #include <ace/Semaphore.h>
30 #include <ace/Task.h>
31 
32 
34 {
35  public:
37  void run();
38  void setListenArguments(std::string host, uint16 port)
39  {
40  m_host = host;
41  m_port = port;
42  }
43  private:
44  std::string m_host;
46 };
47 
48 class SOAPWorkingThread : public ACE_Task<ACE_MT_SYNCH>
49 {
50  public:
52  { }
53 
54  virtual int svc (void)
55  {
56  while (1)
57  {
58  ACE_Message_Block* mb = 0;
59  if (this->getq (mb) == -1)
60  {
61  ACE_DEBUG ((LM_INFO,
62  ACE_TEXT ("(%t) Shutting down\n")));
63  break;
64  }
65 
66  // Process the message.
67  process_message (mb);
68  }
69 
70  return 0;
71  }
72  private:
73  void process_message (ACE_Message_Block* mb);
74 };
75 
76 
78 {
79  public:
81  pendingCommands(0, USYNC_THREAD, "pendingCommands")
82  {
83 
84  }
86  {
87  }
88 
89  void appendToPrintBuffer(const char* msg)
90  {
91  m_printBuffer += msg;
92  }
93 
94  ACE_Semaphore pendingCommands;
95 
96  void setCommandSuccess(bool val)
97  {
98  m_success = val;
99  }
101  {
102  return m_success;
103  }
104 
105  static void print(void* callbackArg, const char* msg)
106  {
107  ((SOAPCommand*)callbackArg)->appendToPrintBuffer(msg);
108  }
109 
110  static void commandFinished(void* callbackArg, bool success);
111 
112  bool m_success;
113  std::string m_printBuffer;
114 };
115 
116 #endif
117 
ACE_Semaphore pendingCommands
Definition: OCSoap.h:94
uint16 m_port
Definition: OCSoap.h:45
std::string m_host
Definition: OCSoap.h:44
static void print(void *callbackArg, const char *msg)
Definition: OCSoap.h:105
void setCommandSuccess(bool val)
Definition: OCSoap.h:96
OCSoapRunnable()
Definition: OCSoap.h:36
bool hasCommandSucceeded()
Definition: OCSoap.h:100
void run()
Definition: OCSoap.cpp:22
SOAPCommand()
Definition: OCSoap.h:80
virtual int svc(void)
Definition: OCSoap.h:54
bool m_success
Definition: OCSoap.h:112
void appendToPrintBuffer(const char *msg)
Definition: OCSoap.h:89
void setListenArguments(std::string host, uint16 port)
Definition: OCSoap.h:38
std::string m_printBuffer
Definition: OCSoap.h:113
ACE_UINT16 uint16
Definition: Define.h:72
~SOAPCommand()
Definition: OCSoap.h:85