Beispiel #1
0
        public static void InvokeGlobalMessage(object dummyObj)
        {
            var context = GlobalHost.ConnectionManager.GetHubContext <RealTimeUpdateHub>();

            context.Clients.All.updateCoordinates(JsonConvert.SerializeObject(PlaneDataSource.GetUpdatedLocations()));

            //TODO This method will get all current flights and check for collisions and weather conditions
            Globals.FlightsProcessor.ProcessCurrentFlights();
        }
        private Timer timer; // Timer

        protected void Application_Start(object sender, EventArgs e)
        {
            RouteTable.Routes.MapHubs();
            PlaneDataSource.LoadData();
            TimerCallback callback = RealTimeUpdateHub.InvokeGlobalMessage;

            //Initialize the processor
            Globals.FlightsProcessor = new FlightProcessor();
            Globals.FlightsProcessor.ApproachingBadWeather += FlightsProcessorOnApproachingBadWeather;
            Globals.FlightsProcessor.PossibleCollision     += FlightsProcessor_PossibleCollision;

            // Update the position of the airplane
            timer = new Timer(callback, null, 1000, 1000);
        }