/// <summary> /// Constructeur d'un PEER P2P /// </summary> /// <param name="pServer"></param> public Peer(ref UDPServer pServer, IPAddress pExternalIP, int pPort, string CallSign, bool pDisabled = false, bool pLocal = false, List <IPAddress> pInternalIP = null) { m_CallSign = CallSign; P2P = P2PManager.Instance; m_AIMapping = AIMapping.Instance; Server = pServer; m_Data = new AirData(); m_OldData = new AirData(); m_SendData = new AirData(); m_FuturData = new AirData(); m_ActualPos = new AirData(); m_AIData = new AIMoveStruct(); m_ExternalIP = pExternalIP; m_InternalIP = pInternalIP; m_Port = pPort; Log = Logger.Instance; m_bLocal = pLocal; if (!m_bLocal) { m_EP = new IPEndPoint(m_ExternalIP, m_Port); } else { m_EP = null; } m_SC = SCManager.Instance; m_Analyseur = AnalyseurManager.Instance; m_PM = PirepManager.Instance; m_FrameRateArray = new List <double>(); m_bDisabled = true; m_Mutex = new Mutex(); m_sel_iplocal = 0; m_TrySimpleAI = false; Disabled = pDisabled; Visible = false; m_bSpawnable = false; m_bBlockData = false; }
/// <summary> /// Constructeur du Singleton /// </summary> private P2PManager() { Log = Logger.Instance; #if DEBUG Log.LogMessage("P2P Manager : Démarré", Color.Blue, 1); #endif m_Mapper = AIMapping.Instance; Server = new UDPServer(); Peers = new List <Peer>(); Discoverer = new NatDiscoverer(); m_InternalIP = new List <IPAddress>(); m_SCM = SCManager.Instance; m_Analyseur = AnalyseurManager.Instance; m_Analyseur.OnStateChange += M_Analyseur_OnStateChange; CheckAI = new System.Timers.Timer(5000); CheckAI.Elapsed += CheckAI_Elapsed; CheckPropertiesData(); try { // récupération du pointeur sur le contrôle liste des utilisateurs P2P if ((m_lvUsers = ffs2play.getControl("lvUsers") as ListViewEx) == null) { throw new InvalidOperationException("La liste lvUsers n'existe pas"); } // récupération du pointeur sur le contrôle liste des détails Peer if ((m_lvPeerDetail = ffs2play.getControl("lvPeerDetail") as ListViewEx) == null) { throw new InvalidOperationException("La liste lvPeerDetail n'existe pas"); } // récupération du pointeur sur le contrôle liste des utilisateurs P2P if ((m_rtbLogChat = ffs2play.getControl("rtbLogChat") as RichTextBox) == null) { throw new InvalidOperationException("La zone de tchat rtbLogChat n'existe pas"); } } catch (Exception e) { Log.LogMessage("P2P Manager : Erreur Constructeur = " + e.Message, Color.DarkViolet); } try { // Récupératgion de l'adresse IP locale IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName()); foreach (IPAddress ip in host.AddressList) { if (ip.AddressFamily == AddressFamily.InterNetwork) { m_InternalIP.Add(ip); #if DEBUG Log.LogMessage("P2PManager: IP locale trouvée = " + ip.ToString(), Color.DarkBlue, 1); #endif } } if (m_InternalIP.Count == 0) { throw new Exception("IP Locale introuvable"); } } catch (Exception e) { Log.LogMessage("P2P Manager : Erreur Constructeur = " + e.Message, Color.DarkViolet); } m_lvUsers.SelectedIndexChanged += M_lvUsers_SelectedIndexChanged; m_lvUsers.MouseClick += M_lvUsers_MouseClick; m_lvUsers.ItemSelectionChanged += M_lvUsers_ItemSelectionChanged; }