#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 | |
reactor * | get_reactor () const |
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.
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
matador::connector::connector | ( | ) |
Default constructor
|
explicit |
Creates a new connector with the given create handler function
on_new_connection | Function which creates a handler on new connection |
|
inlineoverridevirtual |
Does nothing
Implements matador::handler.
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.
r | Reactor to handle the connector and the created connection |
endpoints | List of endpoints to |
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.
r | Reactor to handle the connector and the created connection |
endpoints | List of endpoints to |
on_new_connection | Function creating a new handler on new connection |
|
overridevirtual |
Returns the handle of the connector. The result will always be zero, because the connector doesn't has a socket
Implements matador::handler.
|
overridevirtual |
Always false because connection is established via timeout
Implements matador::handler.
|
overridevirtual |
Always false because connection is established via timeout
Implements matador::handler.
|
overridevirtual |
Get the name of the handler. The name don't need to be unique. It has only an informational purpose.
Implements matador::handler.
|
override |
Notifies the connector that this handler was closed.
hndlr | Closed handler. |
|
inlineoverridevirtual |
Does nothing
Implements matador::handler.
|
inlineoverridevirtual |
Does nothing
Implements matador::handler.
|
inlineoverridevirtual |
Does nothing
Implements matador::handler.
|
inlineoverridevirtual |
Does nothing
Implements matador::handler.
|
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.
|
inlineoverridevirtual |
Opens the connector. Actually this does nothing at all.
Implements matador::handler.