Network System 0.1.1
High-performance modular networking library for scalable client-server applications
Loading...
Searching...
No Matches
legacy_example::i_client Class Referenceabstract
Collaboration diagram for legacy_example::i_client:
Collaboration graph

Public Types

using receive_callback_t = std::function<void(const std::vector<uint8_t>&)>
 
using connected_callback_t = std::function<void()>
 
using disconnected_callback_t = std::function<void()>
 
using error_callback_t = std::function<void(std::error_code)>
 

Public Member Functions

virtual ~i_client ()=default
 
virtual bool start (std::string_view host, uint16_t port)=0
 
virtual bool stop ()=0
 
virtual bool send (std::vector< uint8_t > &&data)=0
 
virtual bool is_connected () const =0
 
virtual void set_receive_callback (receive_callback_t callback)=0
 
virtual void set_connected_callback (connected_callback_t callback)=0
 
virtual void set_disconnected_callback (disconnected_callback_t callback)=0
 
virtual void set_error_callback (error_callback_t callback)=0
 

Detailed Description

LEGACY PATTERN: Protocol-specific interface usage

Problems with this approach:

  1. Must learn different interfaces for each protocol
  2. Code is tightly coupled to specific protocol
  3. Changing protocols requires significant refactoring
  4. More interfaces to test and maintain

Definition at line 46 of file legacy_client_example.cpp.

Member Typedef Documentation

◆ connected_callback_t

using legacy_example::i_client::connected_callback_t = std::function<void()>

Definition at line 51 of file legacy_client_example.cpp.

◆ disconnected_callback_t

Definition at line 52 of file legacy_client_example.cpp.

◆ error_callback_t

using legacy_example::i_client::error_callback_t = std::function<void(std::error_code)>

Definition at line 53 of file legacy_client_example.cpp.

◆ receive_callback_t

using legacy_example::i_client::receive_callback_t = std::function<void(const std::vector<uint8_t>&)>

Definition at line 50 of file legacy_client_example.cpp.

Constructor & Destructor Documentation

◆ ~i_client()

virtual legacy_example::i_client::~i_client ( )
virtualdefault

Member Function Documentation

◆ is_connected()

virtual bool legacy_example::i_client::is_connected ( ) const
pure virtual

◆ send()

virtual bool legacy_example::i_client::send ( std::vector< uint8_t > && data)
pure virtual

◆ set_connected_callback()

virtual void legacy_example::i_client::set_connected_callback ( connected_callback_t callback)
pure virtual

◆ set_disconnected_callback()

virtual void legacy_example::i_client::set_disconnected_callback ( disconnected_callback_t callback)
pure virtual

◆ set_error_callback()

virtual void legacy_example::i_client::set_error_callback ( error_callback_t callback)
pure virtual

◆ set_receive_callback()

virtual void legacy_example::i_client::set_receive_callback ( receive_callback_t callback)
pure virtual

◆ start()

virtual bool legacy_example::i_client::start ( std::string_view host,
uint16_t port )
pure virtual

◆ stop()

virtual bool legacy_example::i_client::stop ( )
pure virtual

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