Exemplo n.º 1
0
        async Task RegisterClient()
        {
            var request = new RegisterAddressRequest
            {
                UserId  = userId,
                Address = $"{ClientService.Host}:{ClientService.Port}"
            };
            var response = await base.RegisterAddressAsync(request, _metadata);

            if (response.Success == false)
            {
                throw new Exception($"Failed to register client service. {response.Detail}");
            }
        }
Exemplo n.º 2
0
        public override async Task <Response> RegisterAddress(RegisterAddressRequest request, ServerCallContext context)
        {
            await VertifyTokenAsync(context);

            var target = request.Address;
            //var target = context.Peer;
            //target = target.Remove(target.LastIndexOf(':') + 1) + port;

            var client = new GrpcClientServiceClient(target);

            _server.SetUserClient(request.UserId, client);
            _logger?.LogInformation($"User {request.UserId} register address: {target}");
            return(new Response {
                Success = true
            });
        }