public int NewSim(SimConfig cfg) { _simsMutex.WaitOne(); _count = _count + 1; _logger.LogInformation("Creating new sim id#{1}", _count); Simulation s; if (cfg == null) { s = new Simulation(); } else { s = new Simulation(cfg); } WebSimulationViewer w = new WebSimulationViewer(); s.AddView(w); s.RegisterListener(w); _sims.Add(s); _views.Add(w); _simsMutex.ReleaseMutex(); return(_count); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); WebSimulationViewer simViewer = new WebSimulationViewer(); Simulation simulation = new Simulation(); simulation.AddView(simViewer); services.AddSingleton <Simulation>(simulation); services.AddSingleton <WebSimulationViewer>(simViewer); services.AddSingleton <SimulationManager, SimulationManager>(); }