/// <summary> /// Initializes all connected clients with the most current data after a major change in the configuration. /// </summary> /// <param name="context">The context.</param> /// <param name="servers">The servers.</param> /// <param name="persistenceContextProvider">The persistence context provider.</param> /// <returns>The task.</returns> public static async ValueTask InitializeAllClients(IHubContext <ServerListHub> context, IList <IManageableServer> servers, IPersistenceContextProvider persistenceContextProvider) { var currentServerInfos = CreateServerInfos(servers); using (var persistenceContext = persistenceContextProvider.CreateNewConfigurationContext()) { var clients = persistenceContext.Get <GameClientDefinition>().ToList(); await context.Clients.Group(SubscriberGroup).SendCoreAsync(nameof(IServerListClient.Initialize), new object[] { currentServerInfos, clients }).ConfigureAwait(false); } }
private void TestDataInitialization(IPersistenceContextProvider contextProvider) { var initialization = new DataInitialization(contextProvider, new NullLoggerFactory()); initialization.CreateInitialData(); // Loading game configuration using var context = contextProvider.CreateNewConfigurationContext(); var gameConfiguraton = context.Get <DataModel.Configuration.GameConfiguration>().FirstOrDefault(); Assert.That(gameConfiguraton, Is.Not.Null); // Testing loading of an account using var accountContext = contextProvider.CreateNewPlayerContext(gameConfiguraton); var account1 = accountContext.GetAccountByLoginName("test1", "test1"); Assert.That(account1, Is.Not.Null); Assert.That(account1.LoginName, Is.EqualTo("test1")); }