Exemple #1
0
    void Ping(bond::ext::grpc::unary_call<PingRequest, PingResponse> call) override
    {
        PingRequest request = call.request().Deserialize();

        switch (request.Action)
        {
            case PingAction::Identity:
            {
                printf("Received identity request \"%s\"\n", request.Payload.c_str());
                fflush(stdout);

                PingResponse response;
                response.Payload = request.Payload;

                NumRequestsReceived++;

                call.Finish(response);
                Countdown.set();
                break;
            }

            case PingAction::Error:
            {
                printf("Received error request \"%s\"\n", request.Payload.c_str());
                fflush(stdout);

                NumErrorsReceived++;

                call.Finish({ ::grpc::StatusCode::UNIMPLEMENTED, "Application Exception" });
                Countdown.set();
                break;
            }

            default:
            {
                printf("Received unknown request \"%s\"\n", request.Payload.c_str());
                fflush(stdout);

                call.Finish({ ::grpc::StatusCode::UNIMPLEMENTED, "Unknown PingAction" });
                Countdown.set();
                break;
            }
        }
    }
Exemple #2
0
    void SayHello(
        bond::ext::gRPC::unary_call<
            bond::bonded<HelloRequest>,
            HelloReply> call) override
    {
        HelloRequest request = call.request().Deserialize();

        HelloReply reply;
        reply.message = "hello " + request.name;

        call.Finish(reply);
    }