/// <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; }
public ServerlessHub() { HubName = GetType().Name; var store = StaticServiceHubContextStore.Get(); var hubContext = store.GetAsync(HubName).GetAwaiter().GetResult(); _serviceManager = store.ServiceManager; Clients = hubContext.Clients; Groups = hubContext.Groups; UserGroups = hubContext.UserGroups; }
/// <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; }
/// <summary> /// Get the user group manager of this hub. /// </summary> public static async Task <IUserGroupManager> GetUserGroupManagerAsync(this InvocationContext invocationContext) { return((await StaticServiceHubContextStore.Get().GetAsync(invocationContext.Hub)).UserGroups); }
/// <summary> /// Gets an object that can be used to invoke methods on the clients connected to this hub. /// </summary> public static async Task <IHubClients> GetClientsAsync(this InvocationContext invocationContext) { return((await StaticServiceHubContextStore.Get().GetAsync(invocationContext.Hub)).Clients); }
/// <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) { _hubContext = hubContext ?? StaticServiceHubContextStore.Get(ConnectionName).GetAsync(HubName).GetAwaiter().GetResult(); _serviceManager = serviceManager ?? StaticServiceHubContextStore.Get(ConnectionName).ServiceManager; }