Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
socket_session.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2012 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_SESSION_H_
21 #define MIR_FRONTEND_DETAIL_SOCKET_SESSION_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 {
41  std::shared_ptr<MessageReceiver> const& socket_receiver,
42  int id_,
43  std::shared_ptr<ConnectedSessions<SocketSession>> const& connected_sessions,
44  std::shared_ptr<MessageProcessor> const& processor);
45 
46  ~SocketSession() noexcept;
47 
48  int id() const { return id_; }
49 
50  void read_next_message();
51 
52 private:
53  void on_response_sent(boost::system::error_code const& error, std::size_t);
54  void on_new_message(const boost::system::error_code& ec);
55  void on_read_size(const boost::system::error_code& ec);
56 
57  std::shared_ptr<MessageReceiver> const socket_receiver;
58  int const id_;
59  std::shared_ptr<ConnectedSessions<SocketSession>> const connected_sessions;
60  std::shared_ptr<MessageProcessor> processor;
61 
62  static size_t const header_size = 2;
63  char header[header_size];
64  std::vector<char> body;
65 };
66 
67 }
68 }
69 }
70 
71 #endif /* MIR_FRONTEND_DETAIL_SOCKET_SESSION_H_ */
Definition: connected_sessions.h:33
Definition: socket_session.h:38
SocketSession(std::shared_ptr< MessageReceiver > const &socket_receiver, int id_, std::shared_ptr< ConnectedSessions< SocketSession >> const &connected_sessions, std::shared_ptr< MessageProcessor > const &processor)
Definition: socket_session.cpp:39
int id() const
Definition: socket_session.h:48
~SocketSession() noexcept
Definition: socket_session.cpp:51
error
Definition: connector_report_tp.h:60
void read_next_message()
Definition: socket_session.cpp:56

Copyright © 2012,2013 Canonical Ltd.
Generated on Fri Apr 11 21:14:53 UTC 2014