public SignalRTriggerBinding(ParameterInfo parameterInfo, SignalRTriggerAttribute attribute, ISignalRTriggerDispatcher dispatcher, AccessKey[] accessKeys, ServiceHubContext hubContext)
 {
     _parameterInfo      = parameterInfo ?? throw new ArgumentNullException(nameof(parameterInfo));
     _attribute          = attribute ?? throw new ArgumentNullException(nameof(attribute));
     _dispatcher         = dispatcher ?? throw new ArgumentNullException(nameof(dispatcher));
     _accessKeys         = accessKeys ?? throw new ArgumentNullException(nameof(accessKeys));
     _hubContext         = hubContext;
     BindingDataContract = CreateBindingContract(_attribute, _parameterInfo);
 }
 /// <summary>
 /// Leave the parameters to be null when called by Azure Function infrastructure.
 /// Or you can pass in your parameters in testing.
 /// </summary>
 protected ServerlessHub(IServiceHubContext hubContext = null, IServiceManager serviceManager = null)
 {
     HubName         = GetType().Name;
     hubContext      = hubContext ?? StaticServiceHubContextStore.Get().GetAsync(HubName).GetAwaiter().GetResult();
     _serviceManager = serviceManager ?? StaticServiceHubContextStore.Get().ServiceManager;
     Clients         = hubContext.Clients;
     Groups          = hubContext.Groups;
     UserGroups      = hubContext.UserGroups;
     _hubContext     = hubContext as ServiceHubContext;
 }
        public async Task InitAsync()
        {
            var serviceManager = new ServiceManagerBuilder().WithOptions(option =>
            {
                option.ConnectionString     = _connectionString;
                option.ServiceTransportType = _serviceTransportType;
            })
                                 //Uncomment the following line to get more logs
                                 //.WithLoggerFactory(LoggerFactory.Create(builder => builder.AddConsole()))
                                 .BuildServiceManager();

            _hubContext = await serviceManager.CreateHubContextAsync(HubName, default);
        }
        /// <summary>
        /// Leave the parameters to be null when called by Azure Function infrastructure.
        /// Or you can pass in your parameters in testing.
        /// </summary>
        protected ServerlessHub(IServiceHubContext hubContext = null, IServiceManager serviceManager = null)
        {
            var hubContextAttribute = GetType().GetCustomAttribute <SignalRConnectionAttribute>(true);
            var connectionString    = hubContextAttribute?.Connection ?? Constants.AzureSignalRConnectionStringName;

            HubName         = GetType().Name;
            hubContext      = hubContext ?? StaticServiceHubContextStore.Get(connectionString).GetAsync(HubName).GetAwaiter().GetResult();
            _serviceManager = serviceManager ?? StaticServiceHubContextStore.Get(connectionString).ServiceManager;
            Clients         = hubContext.Clients;
            Groups          = hubContext.Groups;
            UserGroups      = hubContext.UserGroups;
            _hubContext     = hubContext as ServiceHubContext;
            ClientManager   = _hubContext?.ClientManager;
        }
Exemplo n.º 5
0
        private async Task <ActionResult> NegotiateBase(string user, ServiceHubContext serviceHubContext)
        {
            if (string.IsNullOrEmpty(user))
            {
                return(BadRequest("User ID is null or empty."));
            }

            var negotiateResponse = await serviceHubContext.NegotiateAsync(new()
            {
                UserId = user,
                EnableDetailedErrors = _enableDetailedErrors
            });

            return(new JsonResult(new Dictionary <string, string>()
            {
                { "url", negotiateResponse.Url },
                { "accessToken", negotiateResponse.AccessToken }
            }));
        }
Exemplo n.º 6
0
 public CustomConnectionHub(ServiceHubContext serviceHubContext) : base(serviceHubContext)
 {
 }
 public CustomConnectionHub(ServiceHubContext <IChatClient> serviceHubContext) : base(serviceHubContext)
 {
 }
Exemplo n.º 8
0
 public NegotiateController(IHubContextStore store, IConfiguration configuration)
 {
     _messageHubContext    = store.MessageHubContext;
     _chatHubContext       = store.ChatHubContext;
     _enableDetailedErrors = configuration.GetValue(EnableDetailedErrors, false);
 }
 public TestStronglyTypedHub(ServiceHubContext <IChatClient> serviceHubContext) : base(serviceHubContext)
 {
 }
 public AzureSignalRClient(ServiceHubContext serviceHubContext)
 {
     _serviceHubContext = serviceHubContext;
 }