コード例 #1
0
        public void OpenJoinServerMenu(string serverIp)
        {
            NitroxServiceLocator.BeginNewLifetimeScope();

            if (joinServerGameObject != null)
            {
                Destroy(joinServerGameObject);
            }

            joinServerGameObject = new GameObject();
            JoinServer joinServerComponent = joinServerGameObject.AddComponent <JoinServer>();

            if (Regex.IsMatch(serverIp, @"^[0-9:\[\]a-f]+$"))
            {
                ResolveIpv6(joinServerComponent, serverIp);
            }
            else if (Regex.IsMatch(serverIp, "^[0-9.:]+$"))
            {
                ResolveIpv4(joinServerComponent, serverIp);
            }
            else
            {
                ResolveHostName(joinServerComponent, serverIp);
            }
        }
コード例 #2
0
        public void OpenJoinServerMenu(string serverIp)
        {
            NitroxServiceLocator.BeginNewLifetimeScope();

            if (joinServerGameObject != null)
            {
                Destroy(joinServerGameObject);
            }

            joinServerGameObject = new GameObject();
            JoinServer joinServerComponent = joinServerGameObject.AddComponent <JoinServer>();
            char       seperator           = ':';

            if (serverIp.Contains(seperator))
            {
                string[] splitIP = serverIp.Split(seperator);
                joinServerComponent.ServerIp   = splitIP[0];
                joinServerComponent.serverPort = int.Parse(splitIP[1]);
            }
            else
            {
                IPHostEntry hostEntry = Dns.GetHostEntry(serverIp);
                joinServerComponent.ServerIp   = hostEntry.AddressList[0].ToString();
                joinServerComponent.serverPort = 11000;
            }
        }
コード例 #3
0
        public void OpenJoinServerMenu(string serverIp)
        {
            NitroxServiceLocator.BeginNewLifetimeScope();

            if (joinServerGameObject != null)
            {
                Destroy(joinServerGameObject);
            }

            joinServerGameObject = new GameObject();
            JoinServer joinServerComponent = joinServerGameObject.AddComponent <JoinServer>();
            string     seperator           = ":";

            if (serverIp.Contains(seperator))
            {
                char     splitter = ':';
                string[] splitIP  = serverIp.Split(splitter);
                joinServerComponent.ServerIp   = splitIP[0];
                joinServerComponent.serverPort = int.Parse(splitIP[1]);
            }
            else
            {
                joinServerComponent.ServerIp   = serverIp;
                joinServerComponent.serverPort = 11000;
            }
        }
コード例 #4
0
 private void ResolveHostName(JoinServer joinServerComponent, string serverIp)
 {
     try
     {
         IPHostEntry hostEntry = Dns.GetHostEntry(serverIp);
         joinServerComponent.ServerIp   = hostEntry.AddressList[0].ToString();
         joinServerComponent.serverPort = 11000;
     }
     catch (SocketException e)
     {
         Log.Error($"Невозможно подключиться по адресу: {serverIp}");
         Log.Error(e.ToString());
     }
 }
コード例 #5
0
 private void ResolveHostName(JoinServer joinServerComponent, string serverIp)
 {
     try
     {
         IPHostEntry hostEntry = Dns.GetHostEntry(serverIp);
         joinServerComponent.ServerIp   = hostEntry.AddressList[0].ToString();
         joinServerComponent.serverPort = 11000;
     }
     catch (SocketException e)
     {
         Log.Error($"Unable to resolve the address: {serverIp}");
         Log.Error(e.ToString());
     }
 }
コード例 #6
0
        public void OpenJoinServerMenu(string serverIp)
        {
            NitroxServiceLocator.BeginNewLifetimeScope();

            if (joinServerGameObject != null)
            {
                Destroy(joinServerGameObject);
            }

            joinServerGameObject = new GameObject();
            JoinServer joinServerComponent = joinServerGameObject.AddComponent <JoinServer>();

            joinServerComponent.ServerIp = serverIp;
        }
コード例 #7
0
        private void ResolveIpv4(JoinServer joinServerComponent, string serverIp)
        {
            char seperator = ':';

            if (serverIp.Contains(seperator))
            {
                string[] splitIP = serverIp.Split(seperator);
                joinServerComponent.ServerIp   = splitIP[0];
                joinServerComponent.serverPort = int.Parse(splitIP[1]);
            }
            else
            {
                joinServerComponent.ServerIp   = serverIp;
                joinServerComponent.serverPort = 11000;
            }
        }
コード例 #8
0
 private void ResolveIpv6(JoinServer joinServerComponent, string serverIp)
 {
     if (serverIp.Contains('['))
     {
         Match splitIP = Regex.Match(serverIp, @"^\[(.*?)\]\:(.*)$");
         if (splitIP.Success)
         {
             joinServerComponent.ServerIp   = splitIP.Groups[1].ToString();
             joinServerComponent.serverPort = int.Parse(splitIP.Groups[2].ToString());
         }
     }
     else
     {
         joinServerComponent.ServerIp   = serverIp;
         joinServerComponent.serverPort = 11000;
     }
 }
コード例 #9
0
        public void OpenJoinServerMenu(string serverIp)
        {
            IPEndPoint endpoint = ResolveIpv4(serverIp) ?? ResolveHostName(serverIp);

            if (endpoint == null)
            {
                Log.InGame($"Unable to resolve remote address: {serverIp}");
                return;
            }

            NitroxServiceLocator.BeginNewLifetimeScope();

            if (joinServerGameObject != null)
            {
                Destroy(joinServerGameObject);
            }

            joinServerGameObject = new GameObject();
            JoinServer joinServerComponent = joinServerGameObject.AddComponent <JoinServer>();

            joinServerComponent.ServerIp   = endpoint.Address.ToString();
            joinServerComponent.ServerPort = endpoint.Port;
        }
コード例 #10
0
        public void Setup(GameObject loadedMultiplayer, GameObject savedGames)
        {
            main = this;
            loadedMultiplayerRef = loadedMultiplayer;
            savedGamesRef        = savedGames;

            //This sucks, but the only way around it is to establish a Subnautica resources cache and reference it everywhere we need it.
            //Given recent push-back on elaborate designs, I've just crammed it here until we can all get on the same page as far as code-quality standards are concerned.
            joinServer = new GameObject("NitroxJoinServer").AddComponent <JoinServer>();
            joinServer.Setup(savedGamesRef);

            multiplayerButton    = savedGamesRef.RequireGameObject("Scroll View/Viewport/SavedGameAreaContent/NewGame");
            savedGameAreaContent = loadedMultiplayerRef.RequireTransform("Scroll View/Viewport/SavedGameAreaContent");
            deleteButtonRef      = savedGamesRef.GetComponent <MainMenuLoadPanel>().saveInstance.GetComponent <MainMenuLoadButton>().deleteButton;

            if (!File.Exists(SERVER_LIST_PATH))
            {
                AddServer("local server", "127.0.0.1", "11000");
            }

            CreateButton(Language.main.Get("Nitrox_AddServer"), ShowAddServerWindow);
            LoadSavedServers();
        }