unilink  0.4.3
A simple C++ library for unified async communication
unilink::wrapper::TcpServer Class Reference

Modernized TCP Server Wrapper. More...

#include <tcp_server.hpp>

Inheritance diagram for unilink::wrapper::TcpServer:
unilink::wrapper::ServerInterface

Classes

struct  Impl
 

Public Member Functions

 TcpServer (uint16_t port)
 
 TcpServer (uint16_t port, std::shared_ptr< boost::asio::io_context > external_ioc)
 
 TcpServer (std::shared_ptr< interface::Channel > channel)
 
 ~TcpServer () override
 
 TcpServer (TcpServer &&) noexcept
 
TcpServeroperator= (TcpServer &&) noexcept
 
 TcpServer (const TcpServer &)=delete
 
TcpServeroperator= (const TcpServer &)=delete
 
std::future< bool > start () override
 
void stop () override
 
bool is_listening () const override
 
bool broadcast (std::string_view data) override
 
bool send_to (size_t client_id, std::string_view data) override
 
ServerInterfaceon_client_connect (ConnectionHandler handler) override
 
ServerInterfaceon_client_disconnect (ConnectionHandler handler) override
 
ServerInterfaceon_data (MessageHandler handler) override
 
ServerInterfaceon_error (ErrorHandler handler) override
 
size_t get_client_count () const override
 
std::vector< size_t > get_connected_clients () const override
 
TcpServerauto_manage (bool manage=true)
 
TcpServerenable_port_retry (bool enable=true, int max_retries=3, int retry_interval_ms=1000)
 
TcpServeridle_timeout (int timeout_ms)
 
TcpServerset_client_limit (size_t max_clients)
 
TcpServerset_unlimited_clients ()
 
TcpServernotify_send_failure (bool enable=true)
 
TcpServerset_manage_external_context (bool manage)
 

Additional Inherited Members

Detailed Description

Modernized TCP Server Wrapper.

Definition at line 46 of file tcp_server.hpp.

Constructor & Destructor Documentation

◆ TcpServer() [1/5]

unilink::wrapper::TcpServer::TcpServer ( uint16_t  port)
explicit

Definition at line 251 of file tcp_server.cc.

◆ TcpServer() [2/5]

unilink::wrapper::TcpServer::TcpServer ( uint16_t  port,
std::shared_ptr< boost::asio::io_context >  external_ioc 
)

Definition at line 252 of file tcp_server.cc.

◆ TcpServer() [3/5]

unilink::wrapper::TcpServer::TcpServer ( std::shared_ptr< interface::Channel channel)
explicit

Definition at line 254 of file tcp_server.cc.

◆ ~TcpServer()

unilink::wrapper::TcpServer::~TcpServer ( )
overridedefault

◆ TcpServer() [4/5]

unilink::wrapper::TcpServer::TcpServer ( TcpServer &&  )
defaultnoexcept

◆ TcpServer() [5/5]

unilink::wrapper::TcpServer::TcpServer ( const TcpServer )
delete

Member Function Documentation

◆ auto_manage()

TcpServer & unilink::wrapper::TcpServer::auto_manage ( bool  manage = true)

Definition at line 309 of file tcp_server.cc.

◆ broadcast()

bool unilink::wrapper::TcpServer::broadcast ( std::string_view  data)
overridevirtual

Implements unilink::wrapper::ServerInterface.

Definition at line 264 of file tcp_server.cc.

◆ enable_port_retry()

TcpServer & unilink::wrapper::TcpServer::enable_port_retry ( bool  enable = true,
int  max_retries = 3,
int  retry_interval_ms = 1000 
)

Definition at line 315 of file tcp_server.cc.

◆ get_client_count()

size_t unilink::wrapper::TcpServer::get_client_count ( ) const
overridevirtual

Implements unilink::wrapper::ServerInterface.

Definition at line 297 of file tcp_server.cc.

◆ get_connected_clients()

std::vector< size_t > unilink::wrapper::TcpServer::get_connected_clients ( ) const
overridevirtual

Implements unilink::wrapper::ServerInterface.

Definition at line 303 of file tcp_server.cc.

◆ idle_timeout()

TcpServer & unilink::wrapper::TcpServer::idle_timeout ( int  timeout_ms)

Definition at line 322 of file tcp_server.cc.

◆ is_listening()

bool unilink::wrapper::TcpServer::is_listening ( ) const
overridevirtual

Implements unilink::wrapper::ServerInterface.

Definition at line 262 of file tcp_server.cc.

◆ notify_send_failure()

TcpServer & unilink::wrapper::TcpServer::notify_send_failure ( bool  enable = true)

Definition at line 348 of file tcp_server.cc.

◆ on_client_connect()

ServerInterface & unilink::wrapper::TcpServer::on_client_connect ( ConnectionHandler  handler)
overridevirtual

Implements unilink::wrapper::ServerInterface.

Definition at line 280 of file tcp_server.cc.

◆ on_client_disconnect()

ServerInterface & unilink::wrapper::TcpServer::on_client_disconnect ( ConnectionHandler  handler)
overridevirtual

Implements unilink::wrapper::ServerInterface.

Definition at line 284 of file tcp_server.cc.

◆ on_data()

ServerInterface & unilink::wrapper::TcpServer::on_data ( MessageHandler  handler)
overridevirtual

Implements unilink::wrapper::ServerInterface.

Definition at line 288 of file tcp_server.cc.

◆ on_error()

ServerInterface & unilink::wrapper::TcpServer::on_error ( ErrorHandler  handler)
overridevirtual

Implements unilink::wrapper::ServerInterface.

Definition at line 292 of file tcp_server.cc.

◆ operator=() [1/2]

TcpServer& unilink::wrapper::TcpServer::operator= ( const TcpServer )
delete

◆ operator=() [2/2]

TcpServer & unilink::wrapper::TcpServer::operator= ( TcpServer &&  )
defaultnoexcept

◆ send_to()

bool unilink::wrapper::TcpServer::send_to ( size_t  client_id,
std::string_view  data 
)
overridevirtual

Implements unilink::wrapper::ServerInterface.

Definition at line 272 of file tcp_server.cc.

◆ set_client_limit()

TcpServer & unilink::wrapper::TcpServer::set_client_limit ( size_t  max_clients)

Definition at line 329 of file tcp_server.cc.

◆ set_manage_external_context()

TcpServer & unilink::wrapper::TcpServer::set_manage_external_context ( bool  manage)

Definition at line 352 of file tcp_server.cc.

◆ set_unlimited_clients()

TcpServer & unilink::wrapper::TcpServer::set_unlimited_clients ( )

Definition at line 339 of file tcp_server.cc.

◆ start()

std::future< bool > unilink::wrapper::TcpServer::start ( )
overridevirtual

Implements unilink::wrapper::ServerInterface.

Definition at line 260 of file tcp_server.cc.

◆ stop()

void unilink::wrapper::TcpServer::stop ( )
overridevirtual

Implements unilink::wrapper::ServerInterface.

Definition at line 261 of file tcp_server.cc.


The documentation for this class was generated from the following files: