44 mMutex(SDL_CreateMutex()),
85 logger->
log(
"IPC: unable to create acceptLoop thread");
96 IPC *
const ipc1 =
reinterpret_cast<IPC*
>(ptr);
97 const int max_length = 1024;
113 char data[max_length] = {0};
122 std::string req(
data);
133 const std::string resp =
strprintf(
"[%u] %s\n",
136 const char *
const respc = resp.c_str();
137 const int len =
CAST_S32(strlen(respc)) + 1;
168 unsigned short port(44007);
169 const char *
const portStr = getenv(
"IPC_PORT");
170 if (portStr !=
nullptr)
171 port =
static_cast<unsigned short>(atoi(portStr));
175 for (
int f = port; f < 65535; f ++)
199 FOR_EACH (STD_VECTOR<std::string>::const_iterator, it,
207 FOR_EACH (STD_VECTOR<std::string>::const_iterator, it,
210 std::string
msg = *it;
211 if (
msg.empty() ||
msg[0] !=
'/')
214 const size_t pos =
msg.find(
' ');
215 const std::string type(
msg, 0, pos);
216 std::string args(
msg,
217 pos == std::string::npos ?
msg.size() : pos + 1);
void chatInput(const std::string &msg) const
static int acceptLoop(void *ptr)
void setPort(const unsigned short port)
volatile bool mThreadLocked
std::vector< std::string > mDelayedCommands
void log(const char *const log_text,...)
void log_r(const char *const log_text,...)
#define FOR_EACH(type, iter, array)
bool msg(InputEvent &event)
std::string trim(std::string const &str)
SDL_Thread * createThread(int(*fn)(void *), const char *const name, void *const data)
void WaitThread(SDL_Thread *const thread)
::SDLNet_SocketSet SocketSet
int send(const TcpNet::Socket sock, const void *const data, const int len)
int resolveHost(IPaddress *const address, const char *const host, const Uint16 port)
void freeSocketSet(const TcpNet::SocketSet set)
int socketReady(const TcpNet::Socket sock)
TcpNet::Socket open(IPaddress *const ip)
int addSocket(const TcpNet::SocketSet set, const TcpNet::Socket sock)
SocketSet allocSocketSet(const int maxsockets)
int checkSockets(const TcpNet::SocketSet set, const Uint32 timeout)
void closeSocket(const TcpNet::Socket socket)
int recv(const TcpNet::Socket sock, void *const data, const int maxlen)
TcpNet::Socket accept(const TcpNet::Socket sock)
std::string strprintf(const char *const format,...)