示例#1
0
 public void getExternalIPwithPF()
 {
     try
     {
         externalIP = "Attempting automated port-fowarding...";
         try
         {
             if (NAT.Discover())
             {
                 Console.WriteLine("Attempting port foward");
                 NAT.ForwardPort(Multiplayer.PORT, ProtocolType.Tcp, "Hacknet (TCP)");
                 externalIP = NAT.GetExternalIP().ToString();
             }
             else
             {
                 ScreenManager.ShowPopup("You dont have UPNP enabled - Internet play will not work");
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex);
         }
         if (!externalIP.Equals("Attempting automated port-fowarding..."))
         {
             return;
         }
         externalIP = "Automated port-fowarding Failed - Internet Play Disabled";
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         externalIP = "Automated port-fowarding Failed - Internet Play Disabled";
     }
 }
示例#2
0
        public static bool UPnPJMMFilePort(int jmmfileport)
        {
            try
            {
                if (NAT.Discover())
                {
                    NAT.ForwardPort(jmmfileport, ProtocolType.Tcp, "JMM File Port");
                    UPnPPortAvailable = true;
                }
                else
                {
                    UPnPPortAvailable = false;
                }
            }
            catch (Exception)
            {
                UPnPPortAvailable = false;
            }

            return(UPnPPortAvailable);
        }