Realistic 3D camera system
3D camera system components
connection.hpp
Go to the documentation of this file.
1 //
2 // connection.hpp
3 // ~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 //
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 //
10 
11 #ifndef HTTP_CONNECTION_HPP
12 #define HTTP_CONNECTION_HPP
13 
14 #include <array>
15 #include <memory>
16 #include <asio.hpp>
17 #include "reply.hpp"
18 #include "request.hpp"
19 #include "request_handler.hpp"
20 #include "request_parser.hpp"
21 
22 namespace http {
23 namespace server {
24 
25 class connection_manager;
26 
28 class connection
29  : public std::enable_shared_from_this<connection>
30 {
31 public:
32  connection(const connection&) = delete;
33  connection& operator=(const connection&) = delete;
34 
37  connection_manager& manager, request_handler& handler);
38 
40  void start();
41 
43  void stop();
44 
45 private:
47  void do_read();
48 
50  void do_write();
51 
53  asio::ip::tcp::socket socket_;
54 
56  connection_manager& connection_manager_;
57 
59  request_handler& request_handler_;
60 
62  std::array<char, 8192> buffer_;
63 
65  request request_;
66 
68  request_parser request_parser_;
69 
71  reply reply_;
72 };
73 
74 typedef std::shared_ptr<connection> connection_ptr;
75 
76 } // namespace server
77 } // namespace http
78 
79 #endif // HTTP_CONNECTION_HPP
connection & operator=(const connection &)=delete
Provides stream-oriented socket functionality.
connection(asio::io_service &io_service, connection_manager &manager, request_handler &handler)
Construct a connection with the given io_service.
Definition: connection.cpp:20
void stop()
Stop all asynchronous operations associated with the connection.
Definition: connection.cpp:41
asio::ip::tcp::socket & socket()
Get the socket associated with the connection.
Definition: connection.cpp:28
boost::shared_ptr< connection > connection_ptr
Definition: connection.hpp:78
void start()
Start the first asynchronous operation for the connection.
Definition: connection.cpp:33