Пример #1
0
        /// <summary>
        /// Start a client in LAN only mode. No relays or punchthrough will be used.
        /// </summary>
        /// <remarks>
        /// You will need the host's LAN ip to connect using this method.
        /// </remarks>
        /// <param name="hostEndPoint"></param>
        public void StartClientLANOnly(IPEndPoint hostEndPoint)
        {
            isLANOnly       = true;
            isNetworkActive = true;

            modeProperty.SetValue(this, NetworkManagerMode.ClientOnly);

            initSingletonMethod.Invoke(this, null);

            if (authenticator != null)
            {
                authenticator.OnStartClient();
                authenticator.OnClientAuthenticated.AddListener(onClientAuthenticated);
            }

            if (runInBackground)
            {
                Application.runInBackground = true;
            }

            if (client != null)
            {
                client.Dispose();
            }

            client = new NobleClient();

            RegisterClientHandlers();
            client.Connect(hostEndPoint, isLANOnly);
            OnStartClient();
        }
Пример #2
0
        /// <summary>Connect to a HostEndPoint, utilizing the Noble Connect relay and punchthrough services.</summary>
        public void StartClient(IPEndPoint hostEndPoint)
        {
            isLANOnly       = false;
            isNetworkActive = true;

            modeProperty.SetValue(this, NetworkManagerMode.ClientOnly);

            initSingletonMethod.Invoke(this, null);

            if (authenticator != null)
            {
                authenticator.OnStartClient();
                authenticator.OnClientAuthenticated.AddListener(onClientAuthenticated);
            }

            if (runInBackground)
            {
                Application.runInBackground = true;
            }

            if (client == null)
            {
                try
                {
                    InitClient();
                }
                catch (SocketException)
                {
                    Logger.Log("Failed to resolve relay server address. Starting in LAN only mode", Logger.Level.Warn);
                    isLANOnly = true;
                    client    = new NobleClient();
                }
            }

            RegisterClientHandlers();
            client.Connect(hostEndPoint, isLANOnly);
            OnStartClient();
        }