JayBeams
0.1
Another project to have fun coding.
|
Handle one connection to the control server. More...
#include <connection.hpp>
Public Types | |
using | socket_type = boost::asio::ip::tcp::socket |
The type of socket used for the connection. More... | |
Public Member Functions | |
connection (socket_type &&sock, std::shared_ptr< request_dispatcher > dispatcher) | |
Create a new connection. More... | |
~connection () | |
Destructor. More... | |
void | run () |
Asynchronously read a HTTP request for this connection. More... | |
connection (connection &&)=default | |
Control copy and assignment. More... | |
connection (connection const &)=default | |
connection & | operator= (connection &&)=delete |
connection & | operator= (connection const &)=delete |
Private Member Functions | |
void | on_read (boost::system::error_code const &ec) |
Handle a completed HTTP request read. More... | |
void | on_write (boost::system::error_code const &ec) |
Handle a completed response write. More... | |
Private Attributes | |
socket_type | sock_ |
std::shared_ptr< request_dispatcher > | dispatcher_ |
boost::asio::io_service::strand | strand_ |
int | id_ |
beast::flat_buffer | sb_ |
request_type | req_ |
Static Private Attributes | |
static std::atomic< int > | idgen |
Handle one connection to the control server.
Definition at line 17 of file connection.hpp.
using jb::ehs::connection::socket_type = boost::asio::ip::tcp::socket |
The type of socket used for the connection.
Definition at line 20 of file connection.hpp.
jb::ehs::connection::connection | ( | socket_type && | sock, |
std::shared_ptr< request_dispatcher > | dispatcher | ||
) |
Create a new connection.
sock | the underlying socket for this connection. |
dispatcher | the handler for the connections. |
Definition at line 8 of file connection.cpp.
References dispatcher_, id_, jb::info, JB_LOG, and sock_.
jb::ehs::connection::~connection | ( | ) |
Destructor.
Definition at line 19 of file connection.cpp.
References dispatcher_, id_, jb::info, and JB_LOG.
|
default |
Control copy and assignment.
|
default |
|
private |
Handle a completed HTTP request read.
Once a HTTP request has been received it needs to be parsed and a response sent back. This function is called by the Beast framework when the read completes.
ec | the error code |
Definition at line 31 of file connection.cpp.
References dispatcher_, id_, jb::info, JB_LOG, req_, sock_, and strand_.
|
private |
Handle a completed response write.
ec | indicate if writing the response resulted in an error. |
Definition at line 51 of file connection.cpp.
References dispatcher_, id_, idgen, jb::info, JB_LOG, and run().
|
delete |
|
delete |
void jb::ehs::connection::run | ( | ) |
Asynchronously read a HTTP request for this connection.
Definition at line 24 of file connection.cpp.
References req_, sb_, sock_, and strand_.
Referenced by on_write().
|
private |
Definition at line 68 of file connection.hpp.
Referenced by connection(), on_read(), on_write(), and ~connection().
|
private |
Definition at line 70 of file connection.hpp.
Referenced by connection(), on_read(), on_write(), and ~connection().
|
staticprivate |
Definition at line 74 of file connection.hpp.
Referenced by on_write().
|
private |
Definition at line 72 of file connection.hpp.
|
private |
Definition at line 71 of file connection.hpp.
Referenced by run().
|
private |
Definition at line 67 of file connection.hpp.
Referenced by connection(), on_read(), and run().
|
private |
Definition at line 69 of file connection.hpp.