Пример #1
0
        public void GlobalSetup()
        {
            var definitionsProvider = new RpcServiceDefinitionsBuilder();

            switch (this.ConnectionType)
            {
            case RpcConnectionType.Grpc:
                this.server = new GrpcCore.Server
                {
                    Services = { SimpleService.BindService(new GrpcSimpleService()) },
                    Ports    = { new GrpcCore.ServerPort("localhost", 50051, GrpcCore.ServerCredentials.Insecure) }
                };
                this.server.Start();

                this.channel       = new GrpcCore.Channel("127.0.0.1:50051", GrpcCore.ChannelCredentials.Insecure);
                this.clientService = new SimpleService.SimpleServiceClient(this.channel);
                break;

#if COREFX
            case RpcConnectionType.NetGrpc:
                this.host = CreateNetGrpcHost();
                host.Start();


                var handler = new System.Net.Http.HttpClientHandler();
                handler.ServerCertificateCustomValidationCallback =
                    (httpRequestMessage, cert, cetChain, policyErrors) =>
                {
                    return(true);
                };
                var channelOptions = new GrpcNet.Client.GrpcChannelOptions()
                {
                    HttpClient        = new System.Net.Http.HttpClient(handler),
                    DisposeHttpClient = true
                };

                this.channel       = GrpcChannel.ForAddress("https://localhost:50051", channelOptions);
                this.clientService = new SimpleService.SimpleServiceClient(channel);
                break;
#endif
            }
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of <c>ClientBase</c> class.
 /// </summary>
 /// <param name="channel">The channel to use for remote call invocation.</param>
 public ClientBase(ChannelBase channel) : base(channel)
 {
 }
Пример #3
0
 /// <summary>Creates a new client for Messaging</summary>
 /// <param name="channel">The channel to use to make remote calls.</param>
 public MessagingClient(grpc.ChannelBase channel) : base(channel)
 {
 }