1 |
|
|
/* |
2 |
|
|
* The ManaPlus Client |
3 |
|
|
* Copyright (C) 2014-2019 The ManaPlus Developers |
4 |
|
|
* Copyright (C) 2019-2021 Andrei Karas |
5 |
|
|
* |
6 |
|
|
* This file is part of The ManaPlus Client. |
7 |
|
|
* |
8 |
|
|
* This program is free software; you can redistribute it and/or modify |
9 |
|
|
* it under the terms of the GNU General Public License as published by |
10 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
11 |
|
|
* any later version. |
12 |
|
|
* |
13 |
|
|
* This program is distributed in the hope that it will be useful, |
14 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
|
|
* GNU General Public License for more details. |
17 |
|
|
* |
18 |
|
|
* You should have received a copy of the GNU General Public License |
19 |
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 |
|
|
*/ |
21 |
|
|
|
22 |
|
|
#ifndef NET_IPC_H |
23 |
|
|
#define NET_IPC_H |
24 |
|
|
|
25 |
|
|
#include "localconsts.h" |
26 |
|
|
|
27 |
|
|
PRAGMACLANG6GCC(GCC diagnostic push) |
28 |
|
|
PRAGMACLANG6GCC(GCC diagnostic ignored "-Wold-style-cast") |
29 |
|
|
#include "net/sdltcpnet.h" |
30 |
|
|
PRAGMACLANG6GCC(GCC diagnostic pop) |
31 |
|
|
|
32 |
|
|
#include "utils/vector.h" |
33 |
|
|
|
34 |
|
|
#include <string> |
35 |
|
|
|
36 |
|
|
class IPC final |
37 |
|
|
{ |
38 |
|
|
public: |
39 |
|
|
/** |
40 |
|
|
* Constructor. |
41 |
|
|
*/ |
42 |
|
|
IPC(); |
43 |
|
|
|
44 |
|
|
A_DELETE_COPY(IPC) |
45 |
|
|
|
46 |
|
|
/** |
47 |
|
|
* Destructor. |
48 |
|
|
*/ |
49 |
|
|
~IPC(); |
50 |
|
|
|
51 |
|
|
bool init(); |
52 |
|
|
|
53 |
|
|
unsigned short getPort() const A_WARN_UNUSED |
54 |
|
|
{ return mPort; } |
55 |
|
|
|
56 |
|
|
void flush(); |
57 |
|
|
|
58 |
|
|
static int acceptLoop(void *ptr); |
59 |
|
|
|
60 |
|
|
static void start(); |
61 |
|
|
|
62 |
|
|
static void stop(); |
63 |
|
|
|
64 |
|
|
private: |
65 |
|
|
void setPort(const unsigned short port) |
66 |
|
|
{ mPort = port; } |
67 |
|
|
|
68 |
|
|
unsigned int mNumReqs; |
69 |
|
|
TcpNet::Socket mSocket; |
70 |
|
|
STD_VECTOR<std::string> mDelayedCommands; |
71 |
|
|
SDL_Thread *mThread; |
72 |
|
|
SDL_mutex *mMutex; |
73 |
|
|
unsigned short mPort; |
74 |
|
|
volatile bool mThreadLocked; |
75 |
|
|
bool mListen; |
76 |
|
|
}; |
77 |
|
|
|
78 |
|
|
extern IPC *ipc; |
79 |
|
|
|
80 |
|
|
#endif // NET_IPC_H |