public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime hostApplicationLifetime) { app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); }); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); app.UseRouting(); app.UseDefaultFiles(); app.UseStaticFiles(); app.UseAuthorization(); app.UseCors("CorsPolicy"); app.UseEndpoints(endpoints => { endpoints.MapHub <ChartHub>("/chart"); endpoints.MapControllers(); }); hostApplicationLifetime.ApplicationStarted.Register(() => { var serviceProvider = app.ApplicationServices; var chartHub = (IHubContext <ChartHub>)serviceProvider.GetService(typeof(IHubContext <ChartHub>)); var timer = new System.Timers.Timer { Interval = 500, Enabled = true }; timer.Elapsed += delegate(object sender, System.Timers.ElapsedEventArgs e) { var chartHubConnections = (ChartHubConnections)serviceProvider.GetService(typeof(ChartHubConnections)); var dataSourceFromFiles = (DataSourceFromFiles)serviceProvider.GetService(typeof(DataSourceFromFiles)); foreach (var conn in chartHubConnections.Connections) { //var chart = FakeData.GetChartData(conn.Value); var chart = FakeDatas.GetChartDataFromS2PFile(dataSourceFromFiles, conn.Value); chartHub.Clients.Client(conn.Key).SendAsync("SendChart", chart); } //chartHub.Clients.All.SendAsync("SendChart", chart); }; timer.Start(); }); }
public async Task SendChart() { var chart = FakeDatas.GetChartData(); await Clients.All.SendChart("SendChart", chart); }
public ResonatorParameters GetEmptyResonator() => FakeDatas.GetFakeEmptyResonator();