コード例 #1
0
        public void OnAircraftConfigurationInfoReceived(object sender, NetworkDataReceivedEventArgs e)
        {
            AircraftConfigurationInfo info;

            try
            {
                info = AircraftConfigurationInfo.FromJson(e.Data);
            }
            catch
            {
                return;
            }
            if (info.Request.HasValue)
            {
                switch (info.Request.Value)
                {
                case AircraftConfigurationInfo.RequestType.Full:
                {
                    AircraftConfiguration cfg = AircraftConfiguration.FromUserAircraftData(UserAircraftData);
                    cfg.IsFullData = true;
                    mFsdManager.SendAircraftConfiguration(e.From, cfg);
                    break;
                }
                }
            }
        }
コード例 #2
0
        public void OnAircraftConfigurationInfoReceived(object sender, NetworkDataReceivedEventArgs e)
        {
            AircraftConfigurationInfo aircraftConfigurationInfo;

            try
            {
                aircraftConfigurationInfo = AircraftConfigurationInfo.FromJson(e.Data);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Unable to deserialize aircraft configuration JSON from {e.From}: {e.Data} - Error: {ex.Message}");
                return;
            }
            NetworkAircraft aircraft = mNetworkAircraft.FirstOrDefault(o => o.Callsign == e.From);

            if (aircraftConfigurationInfo.HasConfig && aircraft != null)
            {
                if (!aircraft.SupportsConfigurationProtocol)
                {
                    aircraft.SupportsConfigurationProtocol = true;
                    mFsdManager.RequestFullAircraftConfiguration(aircraft.Callsign);
                    Console.WriteLine($"Received aircraft configuration from {e.From}. Requesting full ACCONFIG again.");
                }

                if (aircraft.Status == AircraftStatus.Active)
                {
                    Console.WriteLine($"Received aircraft configuration info from: {e.From}: {e.Data}");
                    ProcessAircraftConfig(aircraft, aircraftConfigurationInfo.Config);
                }
                else
                {
                    Console.WriteLine($"Queing ACCONFIG for {e.From} because the aircraft isn't active yet.");
                    aircraft.PendingAircraftConfiguration.Push(aircraftConfigurationInfo.Config);
                }
            }
        }