773da77abce4bd065a17f93dbb53d67c5d577a93
[iec.git] / src / type3_AndroidCloud / anbox-master / src / anbox / network / message_receiver.h
1 /*
2  * Copyright © 2013-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: Kevin DuBois <kevin.dubois@canonical.com>
17  */
18
19 #ifndef ANBOX_NETWORK_MESSAGE_RECEIVER_H_
20 #define ANBOX_NETWORK_MESSAGE_RECEIVER_H_
21
22 #include <boost/asio.hpp>
23 #include <functional>
24 #include <vector>
25
26 #include "anbox/common/fd.h"
27
28 namespace anbox {
29 namespace network {
30 class MessageReceiver {
31  public:
32   // receive message from the socket. 'handler' will be called when 'buffer' has
33   // been filled with exactly 'size'
34   typedef std::function<void(boost::system::error_code const&, size_t)>
35       AnboxReadHandler;
36   virtual void async_receive_msg(
37       AnboxReadHandler const& handler,
38       boost::asio::mutable_buffers_1 const& buffer) = 0;
39   virtual boost::system::error_code receive_msg(
40       boost::asio::mutable_buffers_1 const& buffer) = 0;
41   virtual size_t available_bytes() = 0;
42
43  protected:
44   MessageReceiver() = default;
45   virtual ~MessageReceiver() = default;
46   MessageReceiver(MessageReceiver const&) = delete;
47   MessageReceiver& operator=(MessageReceiver const&) = delete;
48 };
49 }  // namespace network
50 }  // namespace anbox
51
52 #endif