Fix small problems with RPC implementation
This commit is contained in:
parent
4abe483ac6
commit
4d94de8507
4 changed files with 9 additions and 10 deletions
|
|
@ -47,8 +47,6 @@ void ConnectionCreator::create_connection_for(
|
|||
return;
|
||||
}
|
||||
|
||||
DEBUG("");
|
||||
|
||||
auto const messenger = std::make_shared<network::SocketMessenger>(socket);
|
||||
auto const processor = message_processor_factory_(messenger);
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ namespace anbox {
|
|||
namespace bridge {
|
||||
class ConnectionCreator : public network::ConnectionCreator {
|
||||
public:
|
||||
typedef std::function<std::shared_ptr<network::MessageProcessor>(const std::shared_ptr<network::MessageSender>&)> MessageProcessorFactory;
|
||||
typedef std::function<std::shared_ptr<network::MessageProcessor>(
|
||||
const std::shared_ptr<network::MessageSender>&)> MessageProcessorFactory;
|
||||
|
||||
ConnectionCreator(
|
||||
const std::shared_ptr<Runtime> &rt, const MessageProcessorFactory &factory);
|
||||
|
|
|
|||
|
|
@ -50,10 +50,12 @@ bool MessageProcessor::process_data(const std::vector<std::uint8_t> &data) {
|
|||
for (const auto &byte : data)
|
||||
buffer_.push_back(byte);
|
||||
|
||||
unsigned char const high = buffer_[0];
|
||||
unsigned char const low = buffer_[1];
|
||||
buffer_.shrink_to_fit();
|
||||
|
||||
const auto high = buffer_[0];
|
||||
const auto low = buffer_[1];
|
||||
size_t const message_size = (high << 8) + low;
|
||||
unsigned char const message_type = buffer_[2];
|
||||
const auto message_type = buffer_[2];
|
||||
|
||||
// If we don't have yet all bytes for a new message return and wait
|
||||
// until we have all.
|
||||
|
|
@ -74,10 +76,7 @@ bool MessageProcessor::process_data(const std::vector<std::uint8_t> &data) {
|
|||
auto result = make_protobuf_object<protobuf::bridge::Result>();
|
||||
result->ParseFromArray(buffer_.data(), message_size);
|
||||
|
||||
buffer_.erase(buffer_.begin(), buffer_.end() + message_size);
|
||||
|
||||
for (int i = 0; i != result->events_size(); ++i)
|
||||
process_event_sequence(result->events(i));
|
||||
buffer_.erase(buffer_.begin(), buffer_.begin() + message_size);
|
||||
|
||||
pending_calls_->complete_response(*result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ protobuf::bridge::Invocation RpcChannel::invocation_for(std::string const& metho
|
|||
invoke.set_id(next_id());
|
||||
invoke.set_method_name(method_name);
|
||||
invoke.set_parameters(buffer.data(), buffer.size());
|
||||
invoke.set_protocol_version(1);
|
||||
|
||||
return invoke;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue