private async void FsdConsumer_RemoveClientDtoReceived(object sender, DtoReceivedEventArgs <RemoveClientDto> p) { _fsdClients.RemoveAll(c => c.Callsign == p.Dto.Callsign); await _liveFeedProducer.ProduceMessage(p.Dto); Console.WriteLine($"{p.Dto.Callsign} disconnected from 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 void fsdConsumer_PingDtoReceived(object sender, DtoReceivedEventArgs <PingDto> e) { PongDto pongDto = new PongDto(e.Dto.Source, "DSERVER", DtoCount, 1, e.Dto.Data); Client.Write(pongDto + "\r\n"); DtoCount++; }
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 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; } if (!p.Dto.Callsign.ToUpper().Contains("_ATIS")) { FsdController fsdController = _fsdControllers.Find(c => c.Callsign == p.Dto.Callsign); if (fsdController == null) { return; } fsdController.HasControllerData = true; fsdController.Frequency = p.Dto.Frequency.Insert(2, ".").Insert(0, "1"); fsdController.Facility = p.Dto.FacilityType; fsdController.VisualRange = p.Dto.VisualRange; fsdController.LastUpdated = DateTime.UtcNow; } else { FsdAtis fsdAtis = _fsdAtiss.Find(c => c.Callsign == p.Dto.Callsign); if (fsdAtis == null) { return; } fsdAtis.HasControllerData = true; fsdAtis.Frequency = p.Dto.Frequency.Insert(2, ".").Insert(0, "1"); fsdAtis.Facility = p.Dto.FacilityType; fsdAtis.VisualRange = p.Dto.VisualRange; fsdAtis.LastUpdated = DateTime.UtcNow; } }
private async void FsdConsumer_FlightPlanDtoReceived(object sender, DtoReceivedEventArgs <FlightPlanDto> p) { try { if (_fsdPilots.All(c => c.Callsign != p.Dto.Callsign)) { ApiUserData response = await _httpService.GetUserData(p.Dto.Cid); FsdPrefile fsdPrefile = new FsdPrefile { Cid = int.Parse(p.Dto.Cid), Name = $"{response.FirstName} {response.LastName}", Callsign = p.Dto.Callsign, LastUpdated = DateTime.UtcNow, FlightPlan = FillFlightPlanFromDto(p.Dto), }; _fsdPrefiles.Add(fsdPrefile); } else { FsdPilot fsdPilot = _fsdPilots.Find(c => c.Callsign == p.Dto.Callsign); if (fsdPilot == null) { return; } fsdPilot.FlightPlan = FillFlightPlanFromDto(p.Dto); } } catch (Exception e) { Console.WriteLine(e); } }
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 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 void FsdConsumer_AddClientDtoReceived(object sender, DtoReceivedEventArgs <AddClientDto> p) { if (_fsdPilots.Any(c => c.Callsign == p.Dto.Callsign) || _fsdControllers.Any(c => c.Callsign == p.Dto.Callsign) || _fsdAtiss.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; } if (p.Dto.Type == 1) { FsdPilot fsdPilot = new FsdPilot { Cid = int.Parse(p.Dto.Cid), Name = p.Dto.RealName, Callsign = p.Dto.Callsign, Server = p.Dto.Server, LogonTime = DateTime.UtcNow, LastUpdated = DateTime.UtcNow, PilotRatingSet = false, HasPilotData = false }; _fsdPilots.Add(fsdPilot); _fsdPrefiles.RemoveAll(f => f.Callsign == p.Dto.Callsign); } else if (p.Dto.Type != 1 && !p.Dto.Callsign.ToUpper().Contains("_ATIS")) { FsdController fsdController = new FsdController { Cid = int.Parse(p.Dto.Cid), Name = p.Dto.RealName, Callsign = p.Dto.Callsign, Server = p.Dto.Server, Rating = p.Dto.Rating, LogonTime = DateTime.UtcNow, LastUpdated = DateTime.UtcNow, HasControllerData = false }; _fsdControllers.Add(fsdController); } else if (p.Dto.Type != 1 && p.Dto.Callsign.ToUpper().Contains("_ATIS")) { FsdAtis fsdAtis = new FsdAtis { Cid = int.Parse(p.Dto.Cid), Callsign = p.Dto.Callsign, Name = p.Dto.RealName, Rating = p.Dto.Rating, Server = p.Dto.Server, LogonTime = DateTime.UtcNow, LastUpdated = DateTime.UtcNow, HasControllerData = false }; _fsdAtiss.Add(fsdAtis); } }
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 static void fsdConsumer_NotifyDtoReceived(object sender, DtoReceivedEventArgs <NotifyDto> p) { if (p.Dto.Hostname == "127.0.0.1" || p.Dto.Name.ToLower().Contains("data") || p.Dto.Name.ToLower().Contains("afv") || _fsdServers.Any(s => s.Name == p.Dto.Name)) { return; } FsdServer fsdServer = new FsdServer { Ident = p.Dto.Ident, HostnameOrIp = p.Dto.Hostname, Location = p.Dto.Location, Name = p.Dto.Name, ClientsConnectionAllowed = 1 }; _fsdServers.Add(fsdServer); }
private void FsdConsumer_PilotDataDtoReceived(object sender, DtoReceivedEventArgs <PilotDataDto> p) { FsdPilot fsdPilot = _fsdPilots.Find(c => c.Callsign == p.Dto.Callsign); if (fsdPilot == null) { return; } fsdPilot.HasPilotData = true; fsdPilot.Transponder = p.Dto.Transponder.ToString("0000"); fsdPilot.Latitude = p.Dto.Latitude; fsdPilot.Longitude = p.Dto.Longitude; fsdPilot.Altitude = p.Dto.Altitude; fsdPilot.Groundspeed = p.Dto.GroundSpeed; fsdPilot.Heading = p.Dto.Heading; fsdPilot.QnhIHg = Math.Round(29.92 - (p.Dto.PressureDifference / 1000.0), 2); fsdPilot.QnhMb = (int)Math.Round(fsdPilot.QnhIHg * 33.864); fsdPilot.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); }
private void FsdConsumer_RemoveClientDtoReceived(object sender, DtoReceivedEventArgs <RemoveClientDto> p) { _fsdPilots.RemoveAll(c => c.Callsign == p.Dto.Callsign); _fsdControllers.RemoveAll(c => c.Callsign == p.Dto.Callsign); _fsdAtiss.RemoveAll(c => c.Callsign == p.Dto.Callsign); }
protected virtual void OnNotifyDtoReceived(DtoReceivedEventArgs <NotifyDto> e) { EventHandler <DtoReceivedEventArgs <NotifyDto> > handler = NotifyDtoReceived; handler?.Invoke(this, e); }
protected virtual void OnAtisDataDtoReceived(DtoReceivedEventArgs <AtisDataDto> e) { EventHandler <DtoReceivedEventArgs <AtisDataDto> > handler = AtisDataDtoReceived; handler?.Invoke(this, e); }
protected virtual void OnPingDtoReceived(DtoReceivedEventArgs <PingDto> e) { EventHandler <DtoReceivedEventArgs <PingDto> > handler = PingDtoReceived; handler?.Invoke(this, e); }
protected virtual void OnFlightPlanDtoReceived(DtoReceivedEventArgs <FlightPlanDto> e) { EventHandler <DtoReceivedEventArgs <FlightPlanDto> > handler = FlightPlanDtoReceived; handler?.Invoke(this, e); }
protected virtual void OnRemoveClientDtoReceived(DtoReceivedEventArgs <RemoveClientDto> e) { EventHandler <DtoReceivedEventArgs <RemoveClientDto> > handler = RemoveClientDtoReceived; handler?.Invoke(this, e); }
private static void fsdConsumer_RemoveClientDtoReceived(object sender, DtoReceivedEventArgs <RemoveClientDto> p) { _fsdClients.RemoveAll(c => c.Callsign == p.Dto.Callsign); Console.WriteLine($"{p.Dto.Callsign} disconnected from the network."); Console.WriteLine(_fsdClients.Count); }
private async void FsdConsumer_FlightPlanCancelDtoReceived(object sender, DtoReceivedEventArgs <FlightPlanCancelDto> p) { _fsdPrefiles.RemoveAll(c => c.Callsign == p.Dto.Callsign); await _liveFeedProducer.ProduceMessage(p.Dto); }