void Initialize()
        {
            if (initialized)
            {
                return;
            }

            initialized = true;

#if NETSTANDARD
            Application.quitting += Disconnect;
#else
            // TODO - Finish and Fix this to match unity some how.
#endif
#if NETSTANDARD
            if (logger.LogEnabled())
            {
                logger.Log("NetworkServer Created version " + Version.Current);
            }
#else
            if (logger.LogEnabled())
            {
                logger.Log("NetworkServer Created version " + Assembly.GetAssembly(typeof(NetworkServer))?.GetName().Version);
            }
#endif

            //Make sure connections are cleared in case any old connections references exist from previous sessions
            connections.Clear();

#if NETSTANDARD
            if (Transport is null)
            {
                Transport = GetComponent <Transport>();
            }
#endif
            if (Transport == null)
            {
                throw new InvalidOperationException("Transport could not be found for NetworkServer");
            }

            if (authenticator != null)
            {
                authenticator.OnServerAuthenticated += OnAuthenticated;

#if NETSTANDARD
                Connected.AddListener(authenticator.OnServerAuthenticateInternal);
#else
                Connected += authenticator.OnServerAuthenticateInternal;
#endif
            }
            else
            {
                // if no authenticator, consider every connection as authenticated
#if NETSTANDARD
                Connected.AddListener(OnAuthenticated);
#else
                Connected += OnAuthenticated;
#endif
            }
        }
Beispiel #2
0
        void Initialize()
        {
            if (initialized)
            {
                return;
            }

            initialized = true;
            if (logger.LogEnabled())
            {
                logger.Log("NetworkServer Created version " + Version.Current);
            }

            //Make sure connections are cleared in case any old connections references exist from previous sessions
            connections.Clear();

            if (transport == null)
            {
                transport = GetComponent <Transport>();
            }

            if (authenticator != null)
            {
                authenticator.OnServerAuthenticated += OnAuthenticated;

                Connected.AddListener(authenticator.OnServerAuthenticateInternal);
            }
            else
            {
                // if no authenticator, consider every connection as authenticated
                Connected.AddListener(OnAuthenticated);
            }
        }
Beispiel #3
0
        void InitializeAuthEvents()
        {
            if (authenticator != null)
            {
                authenticator.OnClientAuthenticated += OnAuthenticated;

                Connected.AddListener(authenticator.OnClientAuthenticateInternal);
            }
            else
            {
                // if no authenticator, consider connection as authenticated
                Connected.AddListener(OnAuthenticated);
            }
        }
Beispiel #4
0
        void Initialize()
        {
            if (initialized)
            {
                return;
            }

            initialized = true;

            Application.quitting += Disconnect;
            if (logger.LogEnabled())
            {
                logger.Log("NetworkServer Created version " + Version.Current);
            }

            //Make sure connections are cleared in case any old connections references exist from previous sessions
            connections.Clear();

            if (Transport is null)
            {
                Transport = GetComponent <Transport>();
            }
            if (Transport == null)
            {
                throw new InvalidOperationException("Transport could not be found for NetworkServer");
            }

            if (authenticator != null)
            {
                authenticator.OnServerAuthenticated += OnAuthenticated;

                Connected.AddListener(authenticator.OnServerAuthenticateInternal);
            }
            else
            {
                // if no authenticator, consider every connection as authenticated
                Connected.AddListener(OnAuthenticated);
            }
        }
        void InitializeAuthEvents()
        {
            if (authenticator != null)
            {
                authenticator.OnClientAuthenticated += OnAuthenticated;

#if NETSTANDARD
                Connected.AddListener(authenticator.OnClientAuthenticateInternal);
#else
                Connected += authenticator.OnClientAuthenticateInternal;
#endif
            }
            else
            {
                // if no authenticator, consider connection as authenticated
#if NETSTANDARD
                Connected.AddListener(OnAuthenticated);
#else
                Connected += OnAuthenticated;
#endif
            }
        }