/// <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 async Task InitAsync() { var serviceManager = new ServiceManagerBuilder().WithOptions(option => { option.ConnectionString = _connectionString; option.ServiceTransportType = _serviceTransportType; }).Build(); _hubContext = await serviceManager.CreateHubContextAsync(HubName, new LoggerFactory()); }
private async Task Initialize() { serviceManager = new ServiceManagerBuilder().WithOptions(option => { option.ConnectionString = shared.connectionstring; // we choose the REST API. we could also go for websockets transport option.ServiceTransportType = ServiceTransportType.Transient; }).Build(); _hubContext = await serviceManager.CreateHubContextAsync(Shared.hubname, new LoggerFactory()); }
public async Task StartAsync(CancellationToken cancellationToken) { var serviceManager = new ServiceManagerBuilder().WithOptions(option => { option.ConnectionString = _config[ENV_SIGNALR]; }).Build(); _notificationHub = await serviceManager.CreateHubContextAsync(HubName); ConnectToQueue(); }
/// <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; }
private static async Task SendToGroupCore(IServiceHubContext serviceHubContext, Func <Task> sendTask) { await Task.WhenAll(from i in Enumerable.Range(0, _userNames.Length) select serviceHubContext.UserGroups.AddToGroupAsync(_userNames[i], _groupNames[i % _groupNames.Length])); await Task.Delay(_timeout); await sendTask(); await Task.Delay(_timeout); await Task.WhenAll(from i in Enumerable.Range(0, _userNames.Length) select serviceHubContext.UserGroups.RemoveFromGroupAsync(_userNames[i], _groupNames[i % _groupNames.Length])); await Task.Delay(_timeout); await sendTask(); await Task.Delay(_timeout); }
private static async Task SendToGroupCore( IServiceHubContext serviceHubContext, IDictionary <string, List <string> > userGroupDict, Func <Task> sendTask, Func <IServiceHubContext, IDictionary <string, List <string> >, Task> userAddToGroupTask, Func <IServiceHubContext, IDictionary <string, List <string> >, Task> userRemoveFromGroupTask) { await userAddToGroupTask(serviceHubContext, userGroupDict); await Task.Delay(_timeout); await sendTask(); await Task.Delay(_timeout); await userRemoveFromGroupTask(serviceHubContext, userGroupDict); await Task.Delay(_timeout); await sendTask(); await Task.Delay(_timeout); }
/// <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; }
// Use default value = null to reconcile testing and production purpose. public MyHub(IServiceHubContext hubContext = null, IServiceManager serviceManager = null) : base(hubContext, serviceManager) { }
static Task Empty(IServiceHubContext context, IDictionary <string, List <string> > dict) => Task.CompletedTask;
protected override async Task RestSendMessage(IServiceHubContext hubContext) { await RestBroadcastMessage(hubContext); }
private static Task UserRemoveFromAllGroupsAsync(IServiceHubContext serviceHubContext, IDictionary <string, List <string> > userGroupDict) { return(Task.WhenAll(from user in userGroupDict.Keys select serviceHubContext.UserGroups.RemoveFromAllGroupsAsync(user))); }
private static Task UserRemoveFromGroupsOneByOneAsync(IServiceHubContext serviceHubContext, IDictionary <string, List <string> > userGroupDict) { return(Task.WhenAll(from usergroup in userGroupDict select Task.WhenAll(from grp in usergroup.Value select serviceHubContext.UserGroups.RemoveFromGroupAsync(usergroup.Key, grp)))); }
public Functions(IServiceHubContext hubContext = null, IServiceManager serviceManager = null) : base(hubContext, serviceManager) { }
internal ServerlessHub(IServiceManagerStore store) { _hubContext = store.GetOrAddByConnectionStringKey(ConnectionName).GetAsync(HubName).GetAwaiter().GetResult(); _serviceManager = store.GetOrAddByConnectionStringKey(ConnectionName).ServiceManager; }
public GameController(ILogger <GameController> logger, IServiceHubContext hub) { _logger = logger; _hub = hub; }
public AppointmentsController(Task <IServiceHubContext> serviceHubContextTask, ConnectionMultiplexer redisConnection) { this.hubContext = serviceHubContextTask.Result; this.redis = redisConnection.GetDatabase(); }