Ejemplo n.º 1
0
        private async Task AttemptEndpointConnection(EndpointProviderRunner endpointRunner, ServerEndpoint serverEndpoint,
                                                     CancellationToken stoppingToken)
        {
            _logger.LogDebug($"Attempting to connect with {serverEndpoint.Uri}");

            var httpClient = _endpointClientFactory.CreateHttpClient(serverEndpoint);

            if (!(await _serverIdentifyVerifier.VerifyServer(serverEndpoint, httpClient, stoppingToken)))
            {
                return;
            }

            if (stoppingToken.IsCancellationRequested)
            {
                return;
            }

            Endpoint        = serverEndpoint;
            ServicesChannel = new ServicesChannel(EventBus, serverEndpoint, Grpc.Net.Client.GrpcChannel.ForAddress(
                                                      serverEndpoint.Uri, new Grpc.Net.Client.GrpcChannelOptions
            {
                DisposeHttpClient = false,
                HttpClient        = httpClient
            }));

            SetConnectedState();
        }