• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Core.CallOptions类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Grpc.Core.CallOptions的典型用法代码示例。如果您正苦于以下问题:C# CallOptions类的具体用法?C# CallOptions怎么用?C# CallOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CallOptions类属于Grpc.Core命名空间,在下文中一共展示了CallOptions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ListenChatAsync

        public async Task<ICollection<ChatMessage>> ListenChatAsync(int accountId)
        {
            Program.Log($"Starting RPC ListenChatAsync (accountId {accountId})", true);

            // parameters can be passed to call one by one or be composed 
            // into a CallOptions using a fluent syntax.
            var callOptions = new CallOptions()
                .WithCancellationToken(CancellationToken.None)
                .WithDeadline(DateTime.UtcNow.AddMinutes(2))
                .WithHeaders(Metadata.Empty);

            using (var call = _grpcClient.ListenChat(new ChatMessageRequest { AccountId = accountId }, callOptions))
            {
                // Custom response header
                Metadata responseHeader = await call.ResponseHeadersAsync;
                Program.Log($"ListenChatAsync response header {String.Join(",", responseHeader.Select(m => m.ToString()))}");

                var chatMessages = new List<ChatMessage>();
                while (await call.ResponseStream.MoveNext())
                {
                    ChatMessage chatMessage = call.ResponseStream.Current;
                    Program.Log($"RPC ListenChatAsync received {chatMessage}");
                    chatMessages.Add(chatMessage);
                }

                // Custom response trailer
                Metadata responseTrailer = call.GetTrailers();
                Program.Log($"ListenChatAsync response trailer {String.Join(",", responseTrailer.Select(m => m.ToString()))}");

                return chatMessages;
            }
        }
开发者ID:mleenhardt,项目名称:grpc-demo,代码行数:32,代码来源:GameAdminServiceClient.cs


示例2: WithMethods

        public void WithMethods()
        {
            var options = new CallOptions();
            
            var metadata = new Metadata();
            Assert.AreSame(metadata, options.WithHeaders(metadata).Headers);

            var deadline = DateTime.UtcNow;
            Assert.AreEqual(deadline, options.WithDeadline(deadline).Deadline.Value);

            var cancellationToken = new CancellationTokenSource().Token;
            Assert.AreEqual(cancellationToken, options.WithCancellationToken(cancellationToken).CancellationToken);

            var writeOptions = new WriteOptions();
            Assert.AreSame(writeOptions, options.WithWriteOptions(writeOptions).WriteOptions);

            var propagationToken = new ContextPropagationToken(CallSafeHandle.NullInstance, DateTime.UtcNow, 
                CancellationToken.None, ContextPropagationOptions.Default);
            Assert.AreSame(propagationToken, options.WithPropagationToken(propagationToken).PropagationToken);

            var credentials = new FakeCallCredentials();
            Assert.AreSame(credentials, options.WithCredentials(credentials).Credentials);

            // Check that the original instance is unchanged.
            Assert.IsNull(options.Headers);
            Assert.IsNull(options.Deadline);
            Assert.AreEqual(CancellationToken.None, options.CancellationToken);
            Assert.IsNull(options.WriteOptions);
            Assert.IsNull(options.PropagationToken);
            Assert.IsNull(options.Credentials);
        }
开发者ID:ConfusedReality,项目名称:pkg_network_grpc,代码行数:31,代码来源:CallOptionsTest.cs


示例3: WriteOptions_Unary

        public void WriteOptions_Unary()
        {
            helper.UnaryHandler = new UnaryServerMethod<string, string>(async (request, context) =>
            {
                context.WriteOptions = new WriteOptions(WriteFlags.NoCompress);
                return request;
            });

            var callOptions = new CallOptions(writeOptions: new WriteOptions(WriteFlags.NoCompress));
            Calls.BlockingUnaryCall(helper.CreateUnaryCall(callOptions), "abc");
        }
开发者ID:xianglinghui,项目名称:grpc,代码行数:11,代码来源:CompressionTest.cs


示例4: WithMethods

        public void WithMethods()
        {
            var options = new CallOptions();
            
            var metadata = new Metadata();
            Assert.AreSame(metadata, options.WithHeaders(metadata).Headers);

            var deadline = DateTime.UtcNow;
            Assert.AreEqual(deadline, options.WithDeadline(deadline).Deadline.Value);

            var token = new CancellationTokenSource().Token;
            Assert.AreEqual(token, options.WithCancellationToken(token).CancellationToken);

            // Change original instance is unchanged.
            Assert.IsNull(options.Headers);
            Assert.IsNull(options.Deadline);
            Assert.AreEqual(CancellationToken.None, options.CancellationToken);
            Assert.IsNull(options.WriteOptions);
            Assert.IsNull(options.PropagationToken);
            Assert.IsNull(options.Credentials);
        }
开发者ID:xianglinghui,项目名称:grpc,代码行数:21,代码来源:CallOptionsTest.cs


示例5: PropagateCancellation

        public async Task PropagateCancellation()
        {
            helper.UnaryHandler = new UnaryServerMethod<string, string>(async (request, context) =>
            {
                // check that we didn't obtain the default cancellation token.
                Assert.IsTrue(context.CancellationToken.CanBeCanceled);
                return "PASS";
            });

            helper.ClientStreamingHandler = new ClientStreamingServerMethod<string, string>(async (requestStream, context) =>
            {
                var propagationToken = context.CreatePropagationToken();
                Assert.IsNotNull(propagationToken.ParentCall);

                var callOptions = new CallOptions(propagationToken: propagationToken);
                return await Calls.AsyncUnaryCall(helper.CreateUnaryCall(callOptions), "xyz");
            });
                
            var cts = new CancellationTokenSource();
            var call = Calls.AsyncClientStreamingCall(helper.CreateClientStreamingCall(new CallOptions(cancellationToken: cts.Token)));
            await call.RequestStream.CompleteAsync();
            Assert.AreEqual("PASS", await call);
        }
开发者ID:larsonmpdx,项目名称:grpc,代码行数:23,代码来源:ContextPropagationTest.cs


示例6: CreateUnaryCall

 public CallInvocationDetails<string, string> CreateUnaryCall(CallOptions options = default(CallOptions))
 {
     return new CallInvocationDetails<string, string>(channel, unaryMethod, options);
 }
开发者ID:ConfusedReality,项目名称:pkg_network_grpc,代码行数:4,代码来源:MockServiceHelper.cs


示例7: StartBtcdRpc

 public global::Walletrpc.StartBtcdRpcResponse StartBtcdRpc(global::Walletrpc.StartBtcdRpcRequest request, CallOptions options)
 {
   var call = CreateCall(__Method_StartBtcdRpc, options);
   return Calls.BlockingUnaryCall(call, request);
 }
开发者ID:tuxcanfly,项目名称:Paymetheus,代码行数:5,代码来源:ApiGrpc.cs


示例8: CloseWallet

 public global::Walletrpc.CloseWalletResponse CloseWallet(global::Walletrpc.CloseWalletRequest request, CallOptions options)
 {
   var call = CreateCall(__Method_CloseWallet, options);
   return Calls.BlockingUnaryCall(call, request);
 }
开发者ID:tuxcanfly,项目名称:Paymetheus,代码行数:5,代码来源:ApiGrpc.cs


示例9: WalletExists

 public global::Walletrpc.WalletExistsResponse WalletExists(global::Walletrpc.WalletExistsRequest request, CallOptions options)
 {
   var call = CreateCall(__Method_WalletExists, options);
   return Calls.BlockingUnaryCall(call, request);
 }
开发者ID:tuxcanfly,项目名称:Paymetheus,代码行数:5,代码来源:ApiGrpc.cs


示例10: PublishTransaction

 public global::Walletrpc.PublishTransactionResponse PublishTransaction(global::Walletrpc.PublishTransactionRequest request, CallOptions options)
 {
   var call = CreateCall(__Method_PublishTransaction, options);
   return Calls.BlockingUnaryCall(call, request);
 }
开发者ID:tuxcanfly,项目名称:Paymetheus,代码行数:5,代码来源:ApiGrpc.cs


示例11: ImportPrivateKey

 public global::Walletrpc.ImportPrivateKeyResponse ImportPrivateKey(global::Walletrpc.ImportPrivateKeyRequest request, CallOptions options)
 {
   var call = CreateCall(__Method_ImportPrivateKey, options);
   return Calls.BlockingUnaryCall(call, request);
 }
开发者ID:tuxcanfly,项目名称:Paymetheus,代码行数:5,代码来源:ApiGrpc.cs


示例12: BalanceAsync

 public AsyncUnaryCall<global::Walletrpc.BalanceResponse> BalanceAsync(global::Walletrpc.BalanceRequest request, CallOptions options)
 {
   var call = CreateCall(__Method_Balance, options);
   return Calls.AsyncUnaryCall(call, request);
 }
开发者ID:tuxcanfly,项目名称:Paymetheus,代码行数:5,代码来源:ApiGrpc.cs


示例13: Balance

 public global::Walletrpc.BalanceResponse Balance(global::Walletrpc.BalanceRequest request, CallOptions options)
 {
   var call = CreateCall(__Method_Balance, options);
   return Calls.BlockingUnaryCall(call, request);
 }
开发者ID:tuxcanfly,项目名称:Paymetheus,代码行数:5,代码来源:ApiGrpc.cs


示例14: AccountNumberAsync

 public AsyncUnaryCall<global::Walletrpc.AccountNumberResponse> AccountNumberAsync(global::Walletrpc.AccountNumberRequest request, CallOptions options)
 {
   var call = CreateCall(__Method_AccountNumber, options);
   return Calls.AsyncUnaryCall(call, request);
 }
开发者ID:tuxcanfly,项目名称:Paymetheus,代码行数:5,代码来源:ApiGrpc.cs


示例15: AccountNumber

 public global::Walletrpc.AccountNumberResponse AccountNumber(global::Walletrpc.AccountNumberRequest request, CallOptions options)
 {
   var call = CreateCall(__Method_AccountNumber, options);
   return Calls.BlockingUnaryCall(call, request);
 }
开发者ID:tuxcanfly,项目名称:Paymetheus,代码行数:5,代码来源:ApiGrpc.cs


示例16: NextAddress

 public global::Walletrpc.NextAddressResponse NextAddress(global::Walletrpc.NextAddressRequest request, CallOptions options)
 {
   var call = CreateCall(__Method_NextAddress, options);
   return Calls.BlockingUnaryCall(call, request);
 }
开发者ID:tuxcanfly,项目名称:Paymetheus,代码行数:5,代码来源:ApiGrpc.cs


示例17: NextAddressAsync

 public AsyncUnaryCall<global::Walletrpc.NextAddressResponse> NextAddressAsync(global::Walletrpc.NextAddressRequest request, CallOptions options)
 {
   var call = CreateCall(__Method_NextAddress, options);
   return Calls.AsyncUnaryCall(call, request);
 }
开发者ID:tuxcanfly,项目名称:Paymetheus,代码行数:5,代码来源:ApiGrpc.cs


示例18: GetTransactions

 public global::Walletrpc.GetTransactionsResponse GetTransactions(global::Walletrpc.GetTransactionsRequest request, CallOptions options)
 {
   var call = CreateCall(__Method_GetTransactions, options);
   return Calls.BlockingUnaryCall(call, request);
 }
开发者ID:tuxcanfly,项目名称:Paymetheus,代码行数:5,代码来源:ApiGrpc.cs


示例19: ImportPrivateKeyAsync

 public AsyncUnaryCall<global::Walletrpc.ImportPrivateKeyResponse> ImportPrivateKeyAsync(global::Walletrpc.ImportPrivateKeyRequest request, CallOptions options)
 {
   var call = CreateCall(__Method_ImportPrivateKey, options);
   return Calls.AsyncUnaryCall(call, request);
 }
开发者ID:tuxcanfly,项目名称:Paymetheus,代码行数:5,代码来源:ApiGrpc.cs


示例20: GetTransactionsAsync

 public AsyncUnaryCall<global::Walletrpc.GetTransactionsResponse> GetTransactionsAsync(global::Walletrpc.GetTransactionsRequest request, CallOptions options)
 {
   var call = CreateCall(__Method_GetTransactions, options);
   return Calls.AsyncUnaryCall(call, request);
 }
开发者ID:tuxcanfly,项目名称:Paymetheus,代码行数:5,代码来源:ApiGrpc.cs



注:本文中的Grpc.Core.CallOptions类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Core.Channel类代码示例发布时间:2022-05-26
下一篇:
C# Fields.FieldType类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap