NetFlex  0.0.0
C++11 HTTP Server Library.
Public Types | Public Member Functions | List of all members
netflex::http::client Class Reference

#include <client.hpp>

Public Types

typedef std::function< void(bool, request &)> request_handler_t
 
typedef tacopie::tcp_client::disconnection_handler_t disconnection_handler_t
 

Public Member Functions

 client (const std::shared_ptr< tacopie::tcp_client > &tcp_client)
 
 ~client (void)=default
 default dtor
 
 client (const client &)=delete
 copy ctor
 
clientoperator= (const client &)=delete
 assignment operator
 
const std::string & get_host (void) const
 
std::uint32_t get_port (void) const
 
void set_request_handler (const request_handler_t &cb)
 
void set_disconnection_handler (const disconnection_handler_t &cb)
 
void send_response (const response &response)
 
void on_async_read_result (tacopie::tcp_client::read_result &res)
 

Detailed Description

http client represent one client connected to the HTTP server and notify on new requests

Member Typedef Documentation

◆ disconnection_handler_t

typedef tacopie::tcp_client::disconnection_handler_t netflex::http::client::disconnection_handler_t

notify on client disconnection

◆ request_handler_t

typedef std::function<void(bool, request&)> netflex::http::client::request_handler_t

notify on new http request received notify on invalid http request received (err while parsing)

Constructor & Destructor Documentation

◆ client()

netflex::http::client::client ( const std::shared_ptr< tacopie::tcp_client > &  tcp_client)
explicit

ctor

Parameters
tcp_clientunderlying tcp connection

Member Function Documentation

◆ get_host()

const std::string& netflex::http::client::get_host ( void  ) const
Returns
host of the client

◆ get_port()

std::uint32_t netflex::http::client::get_port ( void  ) const
Returns
port of the client

◆ on_async_read_result()

void netflex::http::client::on_async_read_result ( tacopie::tcp_client::read_result &  res)

tcp_client callback called on async_read operation completion

Parameters
resread operation result

◆ send_response()

void netflex::http::client::send_response ( const response response)

send http response to the client this should only be called as a result of receiving a valid http request

◆ set_disconnection_handler()

void netflex::http::client::set_disconnection_handler ( const disconnection_handler_t cb)

define the callback to be called on disconnection

Parameters
cbcallback to be called

◆ set_request_handler()

void netflex::http::client::set_request_handler ( const request_handler_t cb)

define the callback to be called on new valid or invalid http requests

Parameters
cbcallback to be called

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