26 #ifndef SIMPLETCPCLIENTLIST_H 27 #define SIMPLETCPCLIENTLIST_H 46 using client_ptr_t = std::shared_ptr<SimpleTcpClient>;
47 using client_map_t = std::map<defs::connection_t, client_ptr_t>;
85 size_t maxAllowedUnsentAsyncMessages = MAX_UNSENT_ASYNC_MSG_COUNT,
86 size_t memPoolMsgCount = 0);
110 size_t maxAllowedUnsentAsyncMessages = MAX_UNSENT_ASYNC_MSG_COUNT,
111 size_t memPoolMsgCount = 0);
146 void CloseConnections()
const;
148 void ClearConnections();
210 template <
typename T,
typename A = serialize::archives::out_port_bin_t>
215 std::lock_guard<std::mutex> lock(m_mutex);
217 auto clientPtr = FindTcpClient(server);
221 clientPtr = CreateTcpClient(server);
226 return clientPtr->SendMessageToServerAsync<T, A>(message, messageId, responseAddress);
241 template <
typename T,
typename A = serialize::archives::out_port_bin_t>
246 std::lock_guard<std::mutex> lock(m_mutex);
248 bool success =
false;
249 auto clientPtr = FindTcpClient(server);
253 clientPtr = CreateTcpClient(server);
258 success = clientPtr->SendMessageToServerSync<T, A>(message, messageId, responseAddress);
285 std::vector<defs::connection_t> GetServerList()
const;
318 size_t m_maxAllowedUnsentAsyncMessages{MAX_UNSENT_ASYNC_MSG_COUNT};
320 size_t m_memPoolMsgCount{0};
322 client_map_t m_clientMap{};
329 #endif // SIMPLETCPCLIENTLIST_H std::function< void(default_received_message_ptr_t)> default_message_dispatcher_t
Typedef to default message dispatcher function object.
Definition: AsioDefines.h:286
bool SendMessageToServerAsync(defs::connection_t const &server, T const &message, int32_t messageId, defs::connection_t const &responseAddress=defs::NULL_CONNECTION)
Send a full message to the server asynchronously.
Definition: SimpleTcpClientList.h:211
A class implementing a collection of bi-directional simple TCP clients.
Definition: SimpleTcpClientList.h:44
The core_lib namespace.
Definition: AsioDefines.h:59
std::mutex m_mutex
Mutex to make access to map thread safe.
Definition: SimpleTcpClientList.h:309
File containing the simple TCP client class declaration.
eSendOption
Enumeration to control nagle algorithm.
Definition: AsioDefines.h:82
nagleOn - Send when possible.
std::pair< std::string, uint16_t > connection_t
Typedef describing a network connection as (address, port).
Definition: AsioDefines.h:152
boost_asio::io_context boost_iocontext_t
Boost IO context convenience typedef.
Definition: AsioDefines.h:46
bool SendMessageToServerSync(defs::connection_t const &server, T const &message, int32_t messageId, defs::connection_t const &responseAddress=defs::NULL_CONNECTION)
Send a full message to the server synchronously.
Definition: SimpleTcpClientList.h:242
std::vector< char > char_buffer_t
Typedef to generic char buffer based on s std::vector<char>.
Definition: AsioDefines.h:239
const connection_t NULL_CONNECTION
Constant defining a null network connection as ("0.0.0.0", 0).