private void ProcessNewAircraft(string from, NetworkAircraftState state)
        {
            NetworkAircraft aircraft = new NetworkAircraft
            {
                Callsign    = from,
                LastUpdated = DateTime.Now,
                UpdateCount = 1,
                Status      = AircraftStatus.New
            };

            aircraft.StateHistory.Add(state);
            mNetworkAircraft.Add(aircraft);

            Console.WriteLine($"Aircraft discovered: {aircraft.Callsign} - requesting CAPS, sending CAPS, requesting aircraft info");
            mFsdManager.RequestClientCapabilities(aircraft.Callsign);
            mFsdManager.SendClientCaps(aircraft.Callsign);
            mFsdManager.RequestPlaneInformation(aircraft.Callsign);
        }
Пример #2
0
        public void OnControllerUpdated(object sender, ControllerUpdateReceivedEventArgs e)
        {
            if (mControllers.ContainsKey(e.From))
            {
                Controller controller         = mControllers[e.From];
                bool       isValid            = controller.IsValid;
                bool       isFrequencyChanged = e.Frequency != controller.Frequency;
                bool       isLocationChanged  = !e.Location.Equals(controller.Location);
                controller.Frequency           = e.Frequency;
                controller.NormalizedFrequency = e.Frequency.Normalize25KhzFsdFrequency();
                controller.Location            = e.Location;
                controller.LastUpdate          = DateTime.Now;
                ValidateController(controller);
                if (isValid && controller.IsValid)
                {
                    if (isFrequencyChanged)
                    {
                        ControllerFrequencyChanged?.Invoke(this, new ControllerEventArgs(controller));
                    }
                    if (isLocationChanged)
                    {
                        ControllerLocationChanged?.Invoke(this, new ControllerEventArgs(controller));
                    }
                }
            }
            else
            {
                Controller controller = new Controller
                {
                    Callsign            = e.From,
                    Frequency           = e.Frequency,
                    NormalizedFrequency = e.Frequency.Normalize25KhzFsdFrequency(),
                    Location            = e.Location,
                    LastUpdate          = DateTime.Now,
                    RealName            = "Unknown"
                };

                mControllers.Add(controller.Callsign, controller);
                mFsdManager.CheckIfValidATC(controller.Callsign);
                mFsdManager.RequestClientCapabilities(controller.Callsign);
                mFsdManager.RequestRealName(controller.Callsign);
            }
        }