private string GetDestinationUrl(SignalRMessage message)
        {
            // URL based on swagger: https://github.com/Azure/azure-signalr/blob/dev/docs/swagger.json
            var route = GetRoute(message);

            return($"{endpoint}:5002/api/v1-preview/hub/{message.HubName}/{route}");
        }
        public async Task SendAsync(SignalRMessage message)
        {
            var payload = new PayloadMessage
            {
                Target    = message.Target,
                Arguments = message.Arguments
            };

            var destinationUrl = GetDestinationUrl(message);
            var bearer         = GenerateJwtBearer(null, destinationUrl, null, DateTime.UtcNow.AddMinutes(30), accessKey);

            await PostJsonAsync(destinationUrl, payload, bearer);
        }
        private string GetRoute(SignalRMessage message)
        {
            var route = string.Empty;

            if (message.Groups?.Count > 0)
            {
                route = message.Groups.Count == 1
                    ? $"group/{message.Groups[0]}"
                    : $"groups/{string.Join(",", message.Groups)}";
            }
            else if (message.Users?.Count > 0)
            {
                route = message.Users.Count == 1
                    ? $"user/{message.Users[0]}"
                    : $"users/{string.Join(",", message.Users)}";
            }

            return(route);
        }