38 #define cipcs dev::LogOutputStream<IpcSendChannel, true>() 39 #define cipcr dev::LogOutputStream<IpcReceiveChannel, true>() 76 bool fullyWritten =
false;
77 bool errorOccured =
false;
78 S socket = (
S)(reinterpret_cast<intptr_t>(_addInfo));
79 string toSend = _response;
82 size_t bytesWritten =
Write(socket, toSend);
83 if (bytesWritten == 0)
85 else if (bytesWritten < toSend.size())
87 int len = toSend.size() - bytesWritten;
88 toSend = toSend.substr(bytesWritten +
sizeof(
char), len);
92 }
while (!fullyWritten && !errorOccured);
94 return fullyWritten && !errorOccured;
102 bool inString =
false;
111 request.append(buffer, nbytes);
112 while (i < request.size())
115 if (c ==
'\"' && !inString)
120 else if (c ==
'\"' && inString && !escape)
125 else if (inString && c ==
'\\' && !escape)
133 else if (!inString && (c ==
'{' || c ==
'['))
137 else if (!inString && (c ==
'}' || c ==
']'))
142 std::string r = request.substr(0, i + 1);
143 request.erase(0, i + 1);
145 OnRequest(r, reinterpret_cast<void*>((intptr_t)_connection));
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
std::hash for asio::adress
virtual size_t Write(S _connection, std::string const &_data)=0
#define DEV_GUARDED(MUTEX)
Simple block guard.
virtual bool SendResponse(std::string const &_response, void *_addInfo=nullptr)
virtual void CloseConnection(S _socket)=0
virtual size_t Read(S _connection, void *_data, size_t _size)=0
void GenerateResponse(S _connection)
std::thread m_listeningThread
virtual bool StopListening()
The default logging channels.
virtual bool StartListening()
std::unordered_set< S > m_sockets