예제 #1
0
        public async Task <ITriggerBinding> TryCreateAsync(TriggerBindingProviderContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var parameterInfo = context.Parameter;
            var attribute     = parameterInfo.GetCustomAttribute <SignalRTriggerAttribute>(false);

            if (attribute == null)
            {
                return(null);
            }

            if (_webhookException != null)
            {
                throw new NotSupportedException($"SignalR trigger is disabled due to 'AzureWebJobsStorage' connection string is not set or invalid. {_webhookException}");
            }

            var resolvedAttribute = GetParameterResolvedAttribute(attribute, parameterInfo);

            ValidateSignalRTriggerAttributeBinding(resolvedAttribute);

            var accessKeys = _managerStore.GetOrAddByConnectionStringKey(resolvedAttribute.ConnectionStringSetting).AccessKeys;

            var hubContext = await _managerStore.GetOrAddByConnectionStringKey(resolvedAttribute.ConnectionStringSetting).GetAsync(resolvedAttribute.HubName).ConfigureAwait(false);

            return(new SignalRTriggerBinding(parameterInfo, resolvedAttribute, _dispatcher, accessKeys, hubContext as ServiceHubContext));
        }
예제 #2
0
        public async static Task <AzureSignalRClient> GetAzureSignalRClientAsync(string connectionStringKey, string attributeHubName, IServiceManagerStore serviceManagerStore)
        {
            var serviceHubContext = await serviceManagerStore
                                    .GetOrAddByConnectionStringKey(connectionStringKey)
                                    .GetAsync(attributeHubName) as ServiceHubContext;

            return(new AzureSignalRClient(serviceHubContext));
        }
        public async Task <ServiceEndpoint[]> ConvertAsync(SignalREndpointsAttribute input, CancellationToken cancellationToken)
        {
            var hubContext = await _serviceManagerStore
                             .GetOrAddByConnectionStringKey(input.ConnectionStringSetting)
                             .GetAsync(input.HubName).ConfigureAwait(false) as IInternalServiceHubContext;

            return(hubContext.GetServiceEndpoints().ToArray());
        }
예제 #4
0
        public async Task <NegotiationContext> ConvertAsync(
            SignalRNegotiationAttribute input, CancellationToken cancellationToken)
        {
            var serviceHubContext = await _serviceManagerStore
                                    .GetOrAddByConnectionStringKey(input.ConnectionStringSetting)
                                    .GetAsync(input.HubName) as IInternalServiceHubContext;

            var endpoints = serviceHubContext.GetServiceEndpoints();
            var endpointConnectionInfo = await Task.WhenAll(endpoints.Select(async e =>
            {
                var subHubContext      = serviceHubContext.WithEndpoints(new ServiceEndpoint[] { e });
                var azureSignalRClient = new AzureSignalRClient(subHubContext);
                var connectionInfo     = await azureSignalRClient.GetClientConnectionInfoAsync(input.UserId, input.IdToken, input.ClaimTypeList, null);
                return(new EndpointConnectionInfo(e)
                {
                    ConnectionInfo = connectionInfo
                });
            }));

            return(new NegotiationContext {
                Endpoints = endpointConnectionInfo
            });
        }
        private async ValueTask <ServiceHubContext> GetHubContextAsync()
        {
            var hubContext = await serviceManagerStore.GetOrAddByConnectionStringKey(connectionStringKey).GetAsync(HubName);

            return(hubContext as ServiceHubContext);
        }
예제 #6
0
 internal ServerlessHub(IServiceManagerStore store)
 {
     _hubContext     = store.GetOrAddByConnectionStringKey(ConnectionName).GetAsync(HubName).GetAwaiter().GetResult();
     _serviceManager = store.GetOrAddByConnectionStringKey(ConnectionName).ServiceManager;
 }