Mir
socket_connection.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2012-2014 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Alan Griffiths <alan@octopull.co.uk>
17  */
18 
19 
20 #ifndef MIR_FRONTEND_DETAIL_SOCKET_CONNECTION_H_
21 #define MIR_FRONTEND_DETAIL_SOCKET_CONNECTION_H_
22 
24 
25 #include <boost/asio.hpp>
26 
27 #include <sys/types.h>
28 
29 namespace mir
30 {
31 namespace frontend
32 {
33 namespace detail
34 {
35 class MessageProcessor;
36 class MessageReceiver;
37 
39 {
40 public:
42  std::shared_ptr<MessageReceiver> const& message_receiver,
43  int id_,
44  std::shared_ptr<Connections<SocketConnection>> const& connections,
45  std::shared_ptr<MessageProcessor> const& processor);
46 
47  ~SocketConnection() noexcept;
48 
49  int id() const { return id_; }
50 
51  void read_next_message();
52 
53 private:
54  void on_response_sent(boost::system::error_code const& error, std::size_t);
55  void on_new_message(const boost::system::error_code& ec);
56  void on_read_size(const boost::system::error_code& ec);
57 
58  std::shared_ptr<MessageReceiver> const message_receiver;
59  int const id_;
60  std::shared_ptr<Connections<SocketConnection>> const connections;
61  std::shared_ptr<MessageProcessor> processor;
62 
63  static size_t const header_size = 2;
64  char header[header_size];
65  std::vector<char> body;
66 
67  int client_pid = 0;
68 };
69 
70 }
71 }
72 }
73 
74 #endif /* MIR_FRONTEND_DETAIL_SOCKET_CONNECTION_H_ */
All things Mir.
Definition: buffer_stream.h:37
int id() const
Definition: socket_connection.h:49
Definition: connections.h:33
SocketConnection(std::shared_ptr< MessageReceiver > const &message_receiver, int id_, std::shared_ptr< Connections< SocketConnection >> const &connections, std::shared_ptr< MessageProcessor > const &processor)
Definition: socket_connection.h:38

Copyright © 2012,2013 Canonical Ltd.
Generated on Tue Mar 24 16:15:19 UTC 2015