Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
socket_messenger.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013-2014 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 3 as
6  * 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: Kevin DuBois <kevin.dubois@canonical.com>
17  */
18 
19 #ifndef MIR_FRONTEND_SOCKET_MESSENGER_H_
20 #define MIR_FRONTEND_SOCKET_MESSENGER_H_
21 #include "message_sender.h"
22 #include "message_receiver.h"
24 #include <mutex>
25 
26 namespace mir
27 {
28 namespace frontend
29 {
30 namespace detail
31 {
33  public MessageReceiver
34 {
35 public:
36  SocketMessenger(std::shared_ptr<boost::asio::local::stream_protocol::socket> const& socket);
37 
38  void send(char const* data, size_t length, FdSets const& fds) override;
39 
40  void async_receive_msg(MirReadHandler const& handler, boost::asio::mutable_buffers_1 const& buffer) override;
41  boost::system::error_code receive_msg(boost::asio::mutable_buffers_1 const& buffer) override;
42  size_t available_bytes() override;
44 
45 private:
46  void update_session_creds();
47  SessionCredentials creator_creds() const;
48 
49  std::shared_ptr<boost::asio::local::stream_protocol::socket> socket;
50  mir::Fd socket_fd;
51 
52  std::mutex message_lock;
53  SessionCredentials session_creds{0, 0, 0};
54 
55  void send_fds_locked(std::unique_lock<std::mutex> const& lock, std::vector<Fd> const& fds);
56 };
57 }
58 }
59 }
60 
61 #endif /* MIR_FRONTEND_SOCKET_MESSENGER_H_ */
All things Mir.
Definition: aging_buffer.h:24
Definition: socket_messenger.h:32
Definition: message_sender.h:31
void send(char const *data, size_t length, FdSets const &fds) override
Definition: fd.h:33
boost::system::error_code receive_msg(boost::asio::mutable_buffers_1 const &buffer) override
SocketMessenger(std::shared_ptr< boost::asio::local::stream_protocol::socket > const &socket)
Definition: session_credentials.h:27
std::initializer_list< std::vector< Fd > > FdSets
Definition: fd_sets.h:31
void async_receive_msg(MirReadHandler const &handler, boost::asio::mutable_buffers_1 const &buffer) override
SessionCredentials client_creds() override
Definition: message_receiver.h:31
std::function< void(boost::system::error_code const &, size_t)> MirReadHandler
Definition: message_receiver.h:35

Copyright © 2012,2013 Canonical Ltd.
Generated on Fri Oct 10 14:07:14 UTC 2014