2 * Copyright © 2013-2014 Canonical Ltd.
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.
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.
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/>.
16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
19 #ifndef ANBOX_NETWORK_MESSAGE_RECEIVER_H_
20 #define ANBOX_NETWORK_MESSAGE_RECEIVER_H_
22 #include <boost/asio.hpp>
26 #include "anbox/common/fd.h"
30 class MessageReceiver {
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)>
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;
44 MessageReceiver() = default;
45 virtual ~MessageReceiver() = default;
46 MessageReceiver(MessageReceiver const&) = delete;
47 MessageReceiver& operator=(MessageReceiver const&) = delete;
49 } // namespace network