|
Core Library
1.7.0.0
Library containing core utilities and tools for threading, networking, logging, INI and CSV file management etc.
|
TCP connections class to manage the TcpConnection objects. More...
#include <TcpConnections.h>
Public Member Functions | |
| TcpConnections ()=default | |
| Default constructor. | |
| ~TcpConnections ()=default | |
| Default desctructor. | |
| TcpConnections (const TcpConnections &)=delete | |
| Copy constructor - deleted. | |
| TcpConnections & | operator= (const TcpConnections &)=delete |
| Copy assignment operator - deleted. | |
| TcpConnections (TcpConnections &&)=delete | |
| Move constructor - deleted. | |
| TcpConnections & | operator= (TcpConnections &&)=delete |
| Move assignment operator - deleted. | |
| void | Add (defs::tcp_conn_ptr_t const &connection) |
| Add a connection. More... | |
| void | Remove (defs::tcp_conn_ptr_t const &connection) |
| Remove a connection. More... | |
| size_t | Size () const |
| Get the number of connections. More... | |
| bool | Empty () const |
| Is the connection map empty? More... | |
| void | CloseConnections () |
| Close all connections. | |
| bool | SendMessageAsync (const defs::connection_t &target, const defs::char_buffer_t &message) const |
| Send an asynchronous message. More... | |
| bool | SendMessageSync (const defs::connection_t &target, const defs::char_buffer_t &message) const |
| Send a synchronous message. More... | |
| bool | SendMessageToAll (const defs::char_buffer_t &message) const |
| Send an asynchronous message to all connections. More... | |
| defs::connection_t | GetLocalEndForRemoteEnd (const defs::connection_t &remoteEnd) const |
| Get the connection details for one of the remote connections. More... | |
| size_t | NumberOfUnsentAsyncMessages (const defs::connection_t &target) const |
| Get number of unsent async messages. More... | |
| bool | IsConnected (const defs::connection_t &client) const |
| Tells if a given client is currently connected ot the server. More... | |
Private Types | |
| using | tcp_conn_map = std::map< defs::connection_t, defs::tcp_conn_ptr_t > |
| Typedef to our connection map type. | |
Private Attributes | |
| std::mutex | m_mutex |
| Access mutex for thread safety. | |
| tcp_conn_map | m_connections {} |
| The connections map. | |
TCP connections class to manage the TcpConnection objects.
This class is the one of the fundamental building blocks for the other TCP networking classes.
| void core_lib::asio::tcp::TcpConnections::Add | ( | defs::tcp_conn_ptr_t const & | connection | ) |
Add a connection.
| [in] | connection | - Shared pointer to connection object. |
| bool core_lib::asio::tcp::TcpConnections::Empty | ( | ) | const |
Is the connection map empty?
| auto core_lib::asio::tcp::TcpConnections::GetLocalEndForRemoteEnd | ( | const defs::connection_t & | remoteEnd | ) | const |
Get the connection details for one of the remote connections.
| [in] | remoteEnd | - Remote end's connection details. |
Throws std::invalid_argument if remoteEnd is not valid.
| bool core_lib::asio::tcp::TcpConnections::IsConnected | ( | const defs::connection_t & | client | ) | const |
Tells if a given client is currently connected ot the server.
| [in] | target | - Target connection details. |
| size_t core_lib::asio::tcp::TcpConnections::NumberOfUnsentAsyncMessages | ( | const defs::connection_t & | target | ) | const |
Get number of unsent async messages.
| [in] | target | - Target connection details. |
| void core_lib::asio::tcp::TcpConnections::Remove | ( | defs::tcp_conn_ptr_t const & | connection | ) |
Remove a connection.
| [in] | connection | - Shared pointer to connection object. |
| bool core_lib::asio::tcp::TcpConnections::SendMessageAsync | ( | const defs::connection_t & | target, |
| const defs::char_buffer_t & | message | ||
| ) | const |
Send an asynchronous message.
| [in] | target | - Target connection details. |
| [in] | message | - Message buffer to send. |
| bool core_lib::asio::tcp::TcpConnections::SendMessageSync | ( | const defs::connection_t & | target, |
| const defs::char_buffer_t & | message | ||
| ) | const |
Send a synchronous message.
| [in] | target | - Target connection details. |
| [in] | message | - Message buffer to send. |
| bool core_lib::asio::tcp::TcpConnections::SendMessageToAll | ( | const defs::char_buffer_t & | message | ) | const |
Send an asynchronous message to all connections.
| [in] | message | - Message buffer to send. |
| size_t core_lib::asio::tcp::TcpConnections::Size | ( | ) | const |
Get the number of connections.