2 * Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
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, as published
6 * by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef ANBOX_RPC_MESSAGE_PROCESSOR_H_
19 #define ANBOX_RPC_MESSAGE_PROCESSOR_H_
21 #include "anbox/network/message_processor.h"
22 #include "anbox/network/message_sender.h"
23 #include "anbox/rpc/pending_call_cache.h"
27 #include <google/protobuf/message_lite.h>
28 #include <google/protobuf/stubs/common.h>
35 } // namespace protobuf
39 Invocation(anbox::protobuf::rpc::Invocation const& invocation)
40 : invocation_(invocation) {}
42 const ::std::string& method_name() const;
43 const ::std::string& parameters() const;
44 google::protobuf::uint32 id() const;
47 anbox::protobuf::rpc::Invocation const& invocation_;
50 class MessageProcessor : public network::MessageProcessor {
52 MessageProcessor(const std::shared_ptr<network::MessageSender>& sender,
53 const std::shared_ptr<PendingCallCache>& pending_calls);
56 bool process_data(const std::vector<std::uint8_t>& data) override;
58 void send_response(::google::protobuf::uint32 id,
59 google::protobuf::MessageLite* response);
61 virtual void dispatch(Invocation const&) {}
62 virtual void process_event_sequence(const std::string&) {}
65 std::shared_ptr<network::MessageSender> sender_;
66 std::vector<std::uint8_t> buffer_;
67 std::shared_ptr<PendingCallCache> pending_calls_;