コード例 #1
0
ファイル: helloworld.cpp プロジェクト: chadwalters/bond
    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);
    }
コード例 #2
0
ファイル: pingpong_server.cpp プロジェクト: glenfe/bond
    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;
            }
        }
    }
コード例 #3
0
ファイル: pingpong_server.cpp プロジェクト: glenfe/bond
    void PingEvent(bond::ext::grpc::unary_call<PingRequest, bond::reflection::nothing> call) override
    {
        PingRequest request = call.request().Deserialize();

        printf("Received event \"%s\"\n", request.Payload.c_str());
        fflush(stdout);

        NumEventsReceived++;

        Countdown.set();
    }