Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 
23 #include "message_processor.h"
24 #include "connected_sessions.h"
25 
26 #include <boost/asio.hpp>
27 
28 #include <sys/types.h>
29 
30 namespace mir
31 {
32 namespace frontend
33 {
34 namespace detail
35 {
36 
37 class MessageReceiver;
38 
40 {
42  std::shared_ptr<MessageReceiver> const& socket_receiver,
43  int id_,
44  std::shared_ptr<ConnectedSessions<SocketSession>> const& connected_sessions,
45  std::shared_ptr<MessageProcessor> const& processor);
46 
47  ~SocketSession() 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 socket_receiver;
59  int const id_;
60  std::shared_ptr<ConnectedSessions<SocketSession>> const connected_sessions;
61  std::shared_ptr<MessageProcessor> processor;
62 
63  boost::asio::streambuf header;
64  boost::asio::streambuf message;
65 };
66 
67 }
68 }
69 }
70 
71 #endif /* MIR_FRONTEND_DETAIL_SOCKET_SESSION_H_ */

Copyright © 2012,2013 Canonical Ltd.
Generated on Tue Oct 15 00:23:28 UTC 2013