Beispiel #1
0
        public override Task <PingResponse> UnaryPing(PingRequest request, ServerCallContext context)
        {
            if (request.Status == Status.Ok)
            {
                return(Task.FromResult(new PingResponse()
                {
                    Message = "OK"
                }));
            }

            global::Grpc.Core.Status status = new global::Grpc.Core.Status(StatusCode.Internal, "details");
            throw new RpcException(status);
        }
Beispiel #2
0
        public override async Task ServerStreamingPing(PingRequest request, IServerStreamWriter <PingResponse> responseStream, ServerCallContext context)
        {
            if (request.Status == Status.Bad)
            {
                ThrowException();
            }

            for (int i = 0; i < 1; i++)
            {
                await responseStream.WriteAsync(new PingResponse()
                {
                    Message = "OK"
                });
            }
        }
Beispiel #3
0
        public override async Task <PingResponse> UnaryPing(PingRequest request, ServerCallContext context)
        {
            if (request.Status == Status.Ok)
            {
                PingResponse response = null;

                await Task.Run(() => response = new PingResponse()
                {
                    Message = "OK"
                });

                return(response);
            }

            global::Grpc.Core.Status status = new global::Grpc.Core.Status(StatusCode.Internal, "details");
            throw new RpcException(status);
        }