/// <summary> /// Notifing the clients that the flight event occured. /// </summary> /// <param name="args">The arrguments processed and send to the client about the event.</param> private void OnFlightMove(FlightMoveArgs args) { IHubContext _hub = GlobalHost.ConnectionManager.GetHubContext <FlightsHub>(); FlightDto flightDto = GetFlightDto(args); _hub.Clients.All.FlightMove(flightDto); }
/// <summary> /// If the flight move to base update the FlightTimeManager /// </summary> private void UpdateFlightsManager(FlightMoveArgs args) { if ((args.OldStation != null) && (args.OldStation.Id == 0)) { _flightsTimeManager.EnterBaseStation(); } }
/// <summary> /// The function being called when the flight event occured. /// </summary> /// <param name="args">The arguments being processed by the event subscribers.</param> private void OnFlightEvent(FlightMoveArgs args) { if (args.StationId != null) { StationModel station = stationsRepository.Get((int)args.StationId); station.FlightId = args.Flight.ID; stationsRepository.Update(station); } if (args.OldStation != null && args.OldStation.Id != 0) { StationModel oldStation = stationsRepository.Get(args.OldStation.Id); oldStation.FlightId = null; stationsRepository.Update(oldStation); } FlightEnterEvent.Invoke(args); }
/// <summary> /// Convert the event arguments to passable object. /// </summary> private FlightDto GetFlightDto(FlightMoveArgs args) { var flight = args.Flight; PlainDto plainDto = new PlainDto { Id = flight.Plain.Id, Sits = flight.Plain.Sits, Name = flight.Plain.Name }; FlightDto flightDto = new FlightDto { ID = flight.ID, StationId = args.StationId, IsDeparture = flight.IsDeparture, IsFinish = flight.IsFinish, FlightName = flight.FlightName, Time = flight.Time, }; return(flightDto); }
/// <summary> /// Notify subscribers on flight event /// </summary> private void NotifyFlightStart(FlightMoveArgs args) { _flightStartEvent.Invoke(args); }
/// <summary> /// Called when flight event occured. /// </summary> /// <param name="args">The handler arguments to be processed .</param> private void OnFlightEnterEvent(FlightMoveArgs args) { UpdateFlightsManager(args); NotifyFlightStart(args); }
/// <summary> /// Occures when the flight reach the last station in it's line. /// </summary> private void OnFlightEnd() { FlightMoveArgs args = new FlightMoveArgs(Flight, null); _flightEvent?.Invoke(args); }
/// <summary> /// Invoking the FlightEvent. /// </summary> /// <param name="oldStation">IStationModel instance to be passed to the handler subscribers.</param> private void OnFlightEnteredEvent(IStationModel oldStation) { FlightMoveArgs args = new FlightMoveArgs(Flight, Id, oldStation); _flightEvent?.Invoke(args); }
private void GetFlightHandlerMock(FlightMoveArgs args) { throw new NotImplementedException(); }