19 #include "async_grpc/rpc_handler.h" 22 #include "cartographer/cloud/proto/map_builder_service.pb.h" 29 void WriteStateHandler::OnRequest(
const google::protobuf::Empty& request) {
30 auto writer = GetWriter();
31 io::ForwardingProtoStreamWriter proto_stream_writer(
32 [writer](
const google::protobuf::Message* proto) {
38 auto response = common::make_unique<proto::WriteStateResponse>();
39 if (proto->GetTypeName() ==
40 "cartographer.mapping.proto.SerializationHeader") {
41 response->mutable_header()->CopyFrom(*proto);
42 }
else if (proto->GetTypeName() ==
43 "cartographer.mapping.proto.SerializedData") {
44 response->mutable_serialized_data()->CopyFrom(*proto);
46 LOG(FATAL) <<
"Unsupported message type: " << proto->GetTypeName();
48 writer.Write(std::move(response));
51 GetContext<MapBuilderContextInterface>()->map_builder().SerializeState(
52 &proto_stream_writer);
53 proto_stream_writer.Close();