matador::connector Class Reference

#include <connector.hpp>

Inherits matador::handler, and handler_creator.

Public Types

typedef std::function< std::shared_ptr< handler >(tcp::socket sock, tcp::peer endpoint, connector *cnnctr)> t_connect_handler
 

Public Member Functions

 connector ()
 
 connector (t_connect_handler on_new_connection)
 
void connect (reactor &r, const std::vector< tcp::peer > &endpoints)
 
void connect (reactor &r, const std::vector< tcp::peer > &endpoints, t_connect_handler on_new_connection)
 
void open () override
 
socket_type handle () const override
 
void on_input () override
 
void on_output () override
 
void on_except () override
 
void on_timeout () override
 
void on_close () override
 
void close () override
 
bool is_ready_write () const override
 
bool is_ready_read () const override
 
void notify_close (handler *hndlr) override
 
std::string name () const override
 
- Public Member Functions inherited from matador::handler
virtual ~handler ()=default
 
time_t next_timeout () const
 
time_t interval () const
 

Additional Inherited Members

- Protected Member Functions inherited from matador::handler
reactorget_reactor () const
 

Detailed Description

Connector which initiates a reactor based connection to a remote network host identified by a list of endpoints.

Once a connection is established a handler is created with the given create handler function. The socket is passed to the created handler.

Member Typedef Documentation

◆ t_connect_handler

typedef std::function<std::shared_ptr<handler>(tcp::socket sock, tcp::peer endpoint, connector *cnnctr)> matador::connector::t_connect_handler

Shortcut to a function creating a handler on successfully execute to a host

Constructor & Destructor Documentation

◆ connector() [1/2]

matador::connector::connector ( )

Default constructor

◆ connector() [2/2]

matador::connector::connector ( t_connect_handler  on_new_connection)
explicit

Creates a new connector with the given create handler function

Parameters
on_new_connectionFunction which creates a handler on new connection

Member Function Documentation

◆ close()

void matador::connector::close ( )
inlineoverridevirtual

Does nothing

Implements matador::handler.

◆ connect() [1/2]

void matador::connector::connect ( reactor r,
const std::vector< tcp::peer > &  endpoints 
)

Initiates a execute to one of the given endpoints within the given reactor. Once a connection is established a new handler for this connection is created. The new connection is dispatched by the reactor.

Parameters
rReactor to handle the connector and the created connection
endpointsList of endpoints to

◆ connect() [2/2]

void matador::connector::connect ( reactor r,
const std::vector< tcp::peer > &  endpoints,
t_connect_handler  on_new_connection 
)

Initiates a execute to one of the given endpoints within the given reactor. Once a connection is established a new handler for this connection is created with the given function. The new connection is dispatched by the reactor.

Parameters
rReactor to handle the connector and the created connection
endpointsList of endpoints to
on_new_connectionFunction creating a new handler on new connection

◆ handle()

socket_type matador::connector::handle ( ) const
overridevirtual

Returns the handle of the connector. The result will always be zero, because the connector doesn't has a socket

Returns
Always zero

Implements matador::handler.

◆ is_ready_read()

bool matador::connector::is_ready_read ( ) const
overridevirtual

Always false because connection is established via timeout

Returns
Always false

Implements matador::handler.

◆ is_ready_write()

bool matador::connector::is_ready_write ( ) const
overridevirtual

Always false because connection is established via timeout

Returns
Always false

Implements matador::handler.

◆ name()

std::string matador::connector::name ( ) const
overridevirtual

Get the name of the handler. The name don't need to be unique. It has only an informational purpose.

Returns
The name of the handler

Implements matador::handler.

◆ notify_close()

void matador::connector::notify_close ( handler hndlr)
override

Notifies the connector that this handler was closed.

Parameters
hndlrClosed handler.

◆ on_close()

void matador::connector::on_close ( )
inlineoverridevirtual

Does nothing

Implements matador::handler.

◆ on_except()

void matador::connector::on_except ( )
inlineoverridevirtual

Does nothing

Implements matador::handler.

◆ on_input()

void matador::connector::on_input ( )
inlineoverridevirtual

Does nothing

Implements matador::handler.

◆ on_output()

void matador::connector::on_output ( )
inlineoverridevirtual

Does nothing

Implements matador::handler.

◆ on_timeout()

void matador::connector::on_timeout ( )
overridevirtual

The timeout call is used to establish the connection. Once the connection could be established within this call the timeout is canceled otherwise it will be tried again after three seconds

Implements matador::handler.

◆ open()

void matador::connector::open ( )
inlineoverridevirtual

Opens the connector. Actually this does nothing at all.

Implements matador::handler.


The documentation for this class was generated from the following file:
  • matador/net/connector.hpp