/// <summary> /// Sends all pending updates to the clients. /// </summary> public void SendUpdates() { var animals = AnimalProvider.GetUpdatedAnimals(); if (animals.Count > 0) { SendAnimalUpdates(_mapHubContext.Clients.All, animals); } var plants = PlantProvider.GetUpdatedPlants(); if (plants.Count > 0) { SendPlantUpdates(_mapHubContext.Clients.All, plants); } }
static void Main(string[] args) { string url = args.Length > 0 ? args[0] : "http://localhost:7777/"; string webRoot = args.Length > 1 ? args[1] : Path.Combine(Environment.CurrentDirectory, "webroot"); var bp = new BlockProvider(Width, Height); var ap = new AnimalProvider(); var pp = new PlantProvider(); using (var server = new WebServer(bp, ap, pp, url, webRoot)) using (var task = RunServer(server, () => { ap.Update(); pp.Update(); })) { _log.Info("Server started on {0}.", url); _log.Info("WebRoot: {0}", webRoot); Console.WriteLine("Press any key to stop.", url, webRoot); Console.ReadLine(); stopped = true; task.Wait(); } }
internal void SendAnimalUpdates(dynamic client, IEnumerable <IAnimal> animals = null) { client.UpdateAnimals((animals ?? AnimalProvider.GetAnimals()).Select(a => new Dto.Animal(a))); }