private async void FsdConsumer_FlightPlanDtoReceived(object sender, DtoReceivedEventArgs <FlightPlanDto> p) { try { FsdClient fsdClient; bool prefile; if (_fsdClients.All(c => c.Callsign != p.Dto.Callsign)) { ApiUserData response = await _httpService.GetUserData(p.Dto.Cid); Console.WriteLine($"Prefile Received for {response.FirstName} {response.LastName}"); fsdClient = new FsdClient { Cid = p.Dto.Cid, Realname = $"{response.FirstName} {response.LastName}", Callsign = p.Dto.Callsign, LastUpdated = DateTime.UtcNow, }; prefile = true; } else { fsdClient = _fsdClients.Find(c => c.Callsign == p.Dto.Callsign); prefile = false; } if (fsdClient == null) { return; } fsdClient.PlannedAircraft = p.Dto.Aircraft; fsdClient.PlannedTascruise = p.Dto.CruiseSpeed; fsdClient.PlannedDepairport = p.Dto.DepartureAirport; fsdClient.PlannedAltitude = p.Dto.Altitude; fsdClient.PlannedDestairport = p.Dto.DestinationAirport; fsdClient.PlannedRevision = p.Dto.Revision; fsdClient.PlannedFlighttype = p.Dto.Type; fsdClient.PlannedDeptime = p.Dto.EstimatedDepartureTime; fsdClient.PlannedActdeptime = p.Dto.ActualDepartureTime; fsdClient.PlannedHrsenroute = p.Dto.HoursEnroute; fsdClient.PlannedMinenroute = p.Dto.MinutesEnroute; fsdClient.PlannedHrsfuel = p.Dto.HoursFuel; fsdClient.PlannedMinfuel = p.Dto.MinutesFuel; fsdClient.PlannedAltairport = p.Dto.AlternateAirport; fsdClient.PlannedRemarks = p.Dto.Remarks; fsdClient.PlannedRoute = p.Dto.Route; if (prefile) { _fsdPrefiles.Add(fsdClient); p.Dto.Prefile = true; } p.Dto.Realname = fsdClient.Realname; await _liveFeedProducer.ProduceMessage(p.Dto); } catch (Exception e) { Console.WriteLine(e); } }
private async void FsdConsumer_AddClientDtoReceived(object sender, DtoReceivedEventArgs <AddClientDto> p) { if (_fsdClients.Any(c => c.Callsign == p.Dto.Callsign) || p.Dto.Callsign == "AFVDATA" || p.Dto.Callsign == "SUP" || p.Dto.Callsign == "DATA" || p.Dto.Callsign == "DATASVR" || p.Dto.Callsign.Contains("DCLIENT") || p.Dto.Callsign == "DATA-TOR" || (p.Dto.Callsign.Length > 3 && p.Dto.Callsign.Substring(0, 4) == "AFVS")) { return; } FsdClient fsdClient = new FsdClient { Callsign = p.Dto.Callsign, Cid = p.Dto.Cid, Protrevision = p.Dto.ProtocolRevision, Rating = p.Dto.Rating, Realname = p.Dto.RealName, Server = p.Dto.Server, Clienttype = p.Dto.Type == 1 ? "PILOT" : "ATC", TimeLogon = DateTime.UtcNow, TimeLastAtisReceived = DateTime.UtcNow, LastUpdated = DateTime.UtcNow }; _fsdClients.Add(fsdClient); _fsdPrefiles.RemoveAll(f => f.Callsign == p.Dto.Callsign); await _liveFeedProducer.ProduceMessage(p.Dto); Console.WriteLine($"{p.Dto.Callsign} connected to the network - {_fsdClients.Count}"); }
private async void FsdConsumer_AtisDataDtoReceived(object sender, DtoReceivedEventArgs <AtisDataDto> p) { FsdClient fsdClient = _fsdClients.Find(c => c.Callsign == p.Dto.From); if (fsdClient == null) { return; } switch (p.Dto.Type) { case "T" when fsdClient.AppendAtis: fsdClient.AtisMessage += $"^§{p.Dto.Data}"; break; case "T": fsdClient.AtisMessage = p.Dto.Data; fsdClient.AppendAtis = true; break; case "E": fsdClient.AppendAtis = false; break; } await _liveFeedProducer.ProduceMessage(p.Dto); }
private static async void fsdConsumer_FlightPlanDtoReceived(object sender, DtoReceivedEventArgs <FlightPlanDto> p) { try { FsdClient fsdClient; bool prefile; if (_fsdClients.All(c => c.Callsign != p.Dto.Callsign)) { string xml = await new WebClient().DownloadStringTaskAsync( $"https://cert.vatsim.net/cert/vatsimnet/idstatus.php?cid={p.Dto.Cid}"); XmlDocument certRecord = new XmlDocument(); certRecord.LoadXml(xml); string lastName = certRecord.SelectSingleNode("/root/user/name_last").InnerText; string firstName = certRecord.SelectSingleNode("/root/user/name_first").InnerText; Console.WriteLine($"Prefile received for {firstName} {lastName}."); fsdClient = new FsdClient { Cid = p.Dto.Cid, Realname = $"{firstName} {lastName}", Callsign = p.Dto.Callsign, LastUpdated = DateTime.UtcNow, }; prefile = true; } else { fsdClient = _fsdClients.Find(c => c.Callsign == p.Dto.Callsign); prefile = false; } fsdClient.PlannedAircraft = p.Dto.Aircraft; fsdClient.PlannedTascruise = p.Dto.CruiseSpeed; fsdClient.PlannedDepairport = p.Dto.DepartureAirport; fsdClient.PlannedAltitude = p.Dto.Altitude; fsdClient.PlannedDestairport = p.Dto.DestinationAirport; fsdClient.PlannedRevision = p.Dto.Revision; fsdClient.PlannedFlighttype = p.Dto.Type; fsdClient.PlannedDeptime = p.Dto.EstimatedDepartureTime; fsdClient.PlannedActdeptime = p.Dto.ActualDepartureTime; fsdClient.PlannedHrsenroute = p.Dto.HoursEnroute; fsdClient.PlannedMinenroute = p.Dto.MinutesEnroute; fsdClient.PlannedHrsfuel = p.Dto.HoursFuel; fsdClient.PlannedMinfuel = p.Dto.MinutesFuel; fsdClient.PlannedAltairport = p.Dto.AlternateAirport; fsdClient.PlannedRemarks = p.Dto.Remarks; fsdClient.PlannedRoute = p.Dto.Route; if (prefile) { _fsdPrefiles.Add(fsdClient); } } catch (Exception e) { Console.WriteLine(e); } }
private async void FsdConsumer_BroadcastDtoReceived(object sender, DtoReceivedEventArgs <BroadcastDto> p) { FsdClient fsdClient = _fsdClients.Find(c => c.Callsign == p.Dto.From); if (fsdClient == null) { return; } p.Dto.Cid = fsdClient.Cid; p.Dto.Realname = fsdClient.Realname; Console.WriteLine($"Broadcast from {p.Dto.From} - {fsdClient.Realname}"); await _liveFeedProducer.ProduceMessage(p.Dto); }
private static void fsdConsumer_PilotDataDtoReceived(object sender, DtoReceivedEventArgs <PilotDataDto> p) { FsdClient fsdClient = _fsdClients.Find(c => c.Callsign == p.Dto.Callsign); fsdClient.Transponder = p.Dto.Transponder; fsdClient.Latitude = p.Dto.Latitude; fsdClient.Longitude = p.Dto.Longitude; fsdClient.Altitude = p.Dto.Altitude; fsdClient.Groundspeed = p.Dto.GroundSpeed; fsdClient.Heading = p.Dto.Heading; fsdClient.QnhIHg = Math.Round(29.92 - (p.Dto.PressureDifference / 1000.0), 2); fsdClient.QnhMb = (int)Math.Round(fsdClient.QnhIHg * 33.864); fsdClient.LastUpdated = DateTime.UtcNow; }
private static void fsdConsumer_AtcDataDtoReceived(object sender, DtoReceivedEventArgs <AtcDataDto> p) { if (p.Dto.Callsign == "AFVDATA" || p.Dto.Callsign == "SUP" || p.Dto.Callsign == "DATA" || p.Dto.Callsign == "DATASVR" || p.Dto.Callsign == "DCLIENT") { return; } FsdClient fsdClient = _fsdClients.Find(c => c.Callsign == p.Dto.Callsign); fsdClient.Frequency = p.Dto.Frequency.Insert(2, ".").Insert(0, "1"); fsdClient.Latitude = p.Dto.Latitude; fsdClient.Longitude = p.Dto.Longitude; fsdClient.Facilitytype = p.Dto.FacilityType; fsdClient.Visualrange = p.Dto.VisualRange; fsdClient.LastUpdated = DateTime.UtcNow; }
private async void FsdConsumer_PilotDataDtoReceived(object sender, DtoReceivedEventArgs <PilotDataDto> p) { FsdClient fsdClient = _fsdClients.Find(c => c.Callsign == p.Dto.Callsign); if (fsdClient == null) { return; } fsdClient.Transponder = p.Dto.Transponder; fsdClient.Latitude = p.Dto.Latitude; fsdClient.Longitude = p.Dto.Longitude; fsdClient.Altitude = p.Dto.Altitude; fsdClient.Groundspeed = p.Dto.GroundSpeed; fsdClient.Heading = p.Dto.Heading; fsdClient.QnhIHg = Math.Round(29.92 - (p.Dto.PressureDifference / 1000.0), 2); fsdClient.QnhMb = (int)Math.Round(fsdClient.QnhIHg * 33.864); fsdClient.LastUpdated = DateTime.UtcNow; await _liveFeedProducer.ProduceMessage(p.Dto); }
private async void FsdConsumer_AtcDataDtoReceived(object sender, DtoReceivedEventArgs <AtcDataDto> p) { if (p.Dto.Callsign == "AFVDATA" || p.Dto.Callsign == "SUP" || p.Dto.Callsign == "DATA" || p.Dto.Callsign == "DATASVR" || p.Dto.Callsign.Contains("DCLIENT") || p.Dto.Callsign == "DATA-TOR" || (p.Dto.Callsign.Length > 3 && p.Dto.Callsign.Substring(0, 4) == "AFVS")) { return; } FsdClient fsdClient = _fsdClients.Find(c => c.Callsign == p.Dto.Callsign); if (fsdClient == null) { return; } fsdClient.Frequency = p.Dto.Frequency.Insert(2, ".").Insert(0, "1"); fsdClient.Latitude = p.Dto.Latitude; fsdClient.Longitude = p.Dto.Longitude; fsdClient.Facilitytype = p.Dto.FacilityType; fsdClient.Visualrange = p.Dto.VisualRange; fsdClient.LastUpdated = DateTime.UtcNow; await _liveFeedProducer.ProduceMessage(p.Dto); }
private static void fsdConsumer_AtisDataDtoReceived(object sender, DtoReceivedEventArgs <AtisDataDto> p) { Console.WriteLine($"ATIS data for {p.Dto.From}: {p.Dto.Data}"); FsdClient fsdClient = _fsdClients.Find(c => c.Callsign == p.Dto.From); if (p.Dto.Type == "T") { if (fsdClient.AppendAtis) { fsdClient.AtisMessage += $"^§{p.Dto.Data}"; } else { fsdClient.AtisMessage = p.Dto.Data; fsdClient.AppendAtis = true; } } else if (p.Dto.Type == "E") { fsdClient.AppendAtis = false; } }
private static void fsdConsumer_AddClientDtoReceived(object sender, DtoReceivedEventArgs <AddClientDto> p) { if (_fsdClients.Any(c => c.Callsign == p.Dto.Callsign) || p.Dto.Callsign == "AFVDATA" || p.Dto.Callsign == "SUP" || p.Dto.Callsign == "DATA" || p.Dto.Callsign == "DATASVR" || p.Dto.Callsign == "DCLIENT") { return; } FsdClient fsdClient = new FsdClient { Callsign = p.Dto.Callsign, Cid = p.Dto.Cid, Protrevision = p.Dto.ProtocolRevision, Rating = p.Dto.Rating, Realname = p.Dto.RealName, Server = p.Dto.Server, Clienttype = p.Dto.Type == 1 ? "PILOT" : "ATC", TimeLogon = DateTime.UtcNow, TimeLastAtisReceived = DateTime.UtcNow, LastUpdated = DateTime.UtcNow }; _fsdClients.Add(fsdClient); Console.WriteLine($"{p.Dto.Callsign} connected to the network."); Console.WriteLine(_fsdClients.Count); }