public void OnRealNameReceived(object sender, NetworkDataReceivedEventArgs e) { if (e.From == tabIdentifier) { WriteName(e.Data); } }
public void OnRealNameReceived(object sender, NetworkDataReceivedEventArgs e) { if (mControllers.ContainsKey(e.From)) { mControllers[e.From].RealName = e.Data; } }
public void OnLegacyPlaneInfoReceived(object sender, NetworkDataReceivedEventArgs e) { NetworkAircraft aircraft = mNetworkAircraft.FirstOrDefault(a => a.Callsign == e.From); if (aircraft != null) { if (aircraft.UpdateCount >= 3) { if (string.IsNullOrEmpty(aircraft.TypeCode)) { Console.WriteLine($"Received legacy aircraft info for {e.From} after {aircraft.UpdateCount} updates with no modern plane info packet received, selecting model based on legacy info."); aircraft.TypeCode = e.Data.IndexOf("-") > -1 ? e.Data.Substring(0, e.Data.IndexOf("-")) : e.Data; AddAircraftToSim(aircraft); } else { Console.WriteLine($"Received legacy aircraft info for {e.From} after having already selected a model, ignorning"); } } else { Console.WriteLine($"Received legacy aircraft info for {e.From} after fewer than 3 updates, ignoring."); } } else { Console.WriteLine($"Received legacy aircraft info for unknown callsign {e.From}, ignoring."); } }
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; } } } }
public void OnRealNameReceived(object sender, NetworkDataReceivedEventArgs e) { var controller = mControllers.FirstOrDefault(o => o.Callsign == e.From); if (controller != null) { controller.RealName = e.Data; } }
public void OnDeletePilotReceived(object sender, NetworkDataReceivedEventArgs e) { NetworkAircraft aircraft = mNetworkAircraft.FirstOrDefault(o => o.Callsign == e.From); if (aircraft != null) { DeleteNetworkAircraft(aircraft); } }
public void OnDeleteControllerReceived(object sender, NetworkDataReceivedEventArgs e) { if (mControllers.ContainsKey(e.From)) { Controller controller = mControllers[e.From]; mControllers.Remove(controller.Callsign); UpdateTransceiverLists(); UpdateRadioTransceivers(); } }
public void OnCapabilitiesResponseReceived(object sender, NetworkDataReceivedEventArgs e) { if (mControllers.ContainsKey(e.From) && e.Data.ToUpper().Contains("NEWINFO=1")) { Controller controller = mControllers[e.From]; if (controller.IsValid && !controller.SupportsNewInfo) { controller.SupportsNewInfo = true; ControllerSupportsNewInfoChanged?.Invoke(this, new ControllerEventArgs(controller)); } } }
public void OnDeleteControllerReceived(object sender, NetworkDataReceivedEventArgs e) { if (mControllers.ContainsKey(e.From)) { Controller controller = mControllers[e.From]; mControllers.Remove(controller.Callsign); if (controller.IsValid) { ControllerDeleted?.Invoke(this, new ControllerEventArgs(controller)); } } }
public void OnCapabilitiesRequestReceived(object sender, NetworkDataReceivedEventArgs e) { if (mNetworkAircraft.Any(a => a.Callsign == e.From)) { Console.WriteLine($"Received capabilities request from {e.From} - requesting aircraft info"); mFsdManager.RequestPlaneInformation(e.From); } else { Console.WriteLine($"Received capabilities request from unknown callsign: {e.From}"); } }
public void OnPrivateMessageReceived(object sender, NetworkDataReceivedEventArgs e) { if (e.From == tabIdentifier) { WriteIncomingMessage(e.Data); PlaySoundRequested(this, new PlaySoundEventArgs(SoundEvent.PrivateMessage)); if ((Parent as TabControl).SelectedTab != this) { ForeColor = Color.Yellow; (Parent as TabControl).Refresh(); } } }
public void OnPrivateMessageReceived(object sender, NetworkDataReceivedEventArgs e) { if (e.From != "SERVER") { dynamic data = new ExpandoObject(); data.From = e.From.ToUpper(); data.Message = e.Data; SendMessage(new XplaneConnect { Type = XplaneConnect.MessageType.PrivateMessageReceived, Timestamp = DateTime.Now, Data = data }.ToJSON()); } }
public void OnCapabilitiesResponseReceived(object sender, NetworkDataReceivedEventArgs e) { Console.WriteLine($"Received capabilities list from: {e.From} - {e.Data}"); if (e.Data.Contains("ACCONFIG=1")) { NetworkAircraft aircraft = mNetworkAircraft.FirstOrDefault(o => o.Callsign == e.From); if (aircraft != null) { Console.WriteLine($"Remote aircraft supports ACCONFIG: {e.From}"); aircraft.SupportsConfigurationProtocol = true; Console.WriteLine($"Requesting full ACCONFIG packet from {e.From}"); mFsdManager.RequestFullAircraftConfiguration(e.From); } } }
public void OnNetworkAircraftInfoReceived(object sender, NetworkDataReceivedEventArgs e) { NetworkAircraft aircraft = mNetworkAircraft.FirstOrDefault(o => o.Callsign == e.From); if (aircraft == null) { Console.WriteLine($"Received aircraft info for an unknown aircraft: {e.From}"); } else { if (!string.IsNullOrEmpty(aircraft.TypeCode)) { if (aircraft.TypeCode != e.Data) { Console.WriteLine($"Received new aircraft info for {e.From} - changing model"); aircraft.TypeCode = e.Data.IndexOf("-") > -1 ? e.Data.Substring(0, e.Data.IndexOf("-")) : e.Data; dynamic data = new ExpandoObject(); data.Callsign = aircraft.Callsign; data.TypeCode = aircraft.TypeCode.Substring(0, Math.Min(4, aircraft.TypeCode.Length)); data.Airline = aircraft.AirlineIcao; XplaneConnect xp = new XplaneConnect { Type = XplaneConnect.MessageType.ChangeModel, Timestamp = DateTime.Now, Data = data }; XPlaneEventPosted?.Invoke(this, new ClientEventArgs <string>(xp.ToJSON())); } else { Console.WriteLine($"Received unchanged aircraft info for {e.From} - already have a model selected"); } } else { aircraft.TypeCode = e.Data.IndexOf("-") > -1 ? e.Data.Substring(0, e.Data.IndexOf("-")) : e.Data; AddAircraftToSim(aircraft); } } }
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); } } }