osrm-backend/docs/source/gRPC/CppUsage.md
Siarhei Fedartsou 0f6aab9da6 Squashed 'third_party/flatbuffers/' content from commit 595bf0007
git-subtree-dir: third_party/flatbuffers
git-subtree-split: 595bf0007ab1929570c7671f091313c8fc20644e
2024-06-22 13:33:34 +02:00

775 B

Use in C++

Before you get started

Before diving into the FlatBuffers gRPC usage in C++, you should already be familiar with the following:

  • FlatBuffers as a serialization format
  • gRPC usage

Using the FlatBuffers gRPC C++ library

NOTE: The examples below are also in the grpc/samples/greeter directory.

We will illustrate usage with the following schema:

@include grpc/samples/greeter/greeter.fbs

When we run flatc, we pass in the --grpc option and generage an additional greeter.grpc.fb.h and greeter.grpc.fb.cc.

Example server code looks like this:

@include grpc/samples/greeter/server.cpp

Example client code looks like this:

@include grpc/samples/greeter/client.cpp