/// <summary> /// Translates the bytes for an <see cref="AircraftListJson"/> into a list of cooked messages and raises the /// appropriate events. /// </summary> /// <param name="now"></param> /// <param name="extractedBytes"></param> private void ProcessAircraftListJsonMessageBytes(DateTime now, ExtractedBytes extractedBytes) { try { var jsonText = Encoding.UTF8.GetString(extractedBytes.Bytes, extractedBytes.Offset, extractedBytes.Length); var json = JsonConvert.DeserializeObject <AircraftListJson>(jsonText, _AircraftListJsonSerialiserSettings); var totalMessages = 0; foreach (var eventArgs in _AircraftListJsonMessageConverter.ConvertIntoBaseStationMessageEventArgs(json)) { ++totalMessages; _MessageProcessingAndDispatchQueue.Enqueue(new MessageDispatch() { Port30003MessageEventArgs = eventArgs }); } if (totalMessages != 0) { TotalMessages += totalMessages; if (Statistics != null) { Statistics.Lock(r => r.BaseStationMessagesReceived += totalMessages); } } } catch (Exception) { ++TotalBadMessages; if (Statistics != null) { Statistics.Lock(r => ++ r.BaseStationBadFormatMessagesReceived); } if (!IgnoreBadMessages) { throw; } } }
/// <summary> /// Translates the bytes for an <see cref="AircraftListJson"/> into a list of cooked messages and raises the /// appropriate events. /// </summary> /// <param name="now"></param> /// <param name="extractedBytes"></param> private void ProcessAircraftListJsonMessageBytes(DateTime now, ExtractedBytes extractedBytes) { ProcessJsonMessageBytes <AircraftListJson>( now, extractedBytes, _AircraftListJsonSerialiserSettings, (json) => _AircraftListJsonMessageConverter.ConvertIntoBaseStationMessageEventArgs(json) ); }
public void AircraftListJsonMessageConverter_Never_Sets_IsOutOfBand() { _AircraftListJson.Aircraft.Add(new AircraftJson() { Icao24 = "A" }); var eventArgs = _Converter.ConvertIntoBaseStationMessageEventArgs(_AircraftListJson).Single(); Assert.IsFalse(eventArgs.IsOutOfBand); }