/// <summary> /// cleanup resources so that we can start again /// </summary> private void Cleanup() { if (authenticator != null) { authenticator.OnServerAuthenticated -= OnAuthenticated; #if NETSTANDARD Connected.RemoveListener(authenticator.OnServerAuthenticateInternal); #else Connected -= authenticator.OnServerAuthenticateInternal; #endif } else { // if no authenticator, consider every connection as authenticated #if NETSTANDARD Connected.RemoveListener(OnAuthenticated); #else Connected -= OnAuthenticated; #endif } Stopped.Invoke(); initialized = false; Active = false; }
/// <summary> /// Shut down a client. /// <para>This should be done when a client is no longer going to be used.</para> /// </summary> void Cleanup() { logger.Log("Shutting down client."); hostServer = null; connectState = ConnectState.Disconnected; if (authenticator != null) { authenticator.OnClientAuthenticated -= OnAuthenticated; #if NETSTANDARD Connected.RemoveListener(authenticator.OnClientAuthenticateInternal); #else Connected -= authenticator.OnClientAuthenticateInternal; #endif } else { // if no authenticator, consider connection as authenticated #if NETSTANDARD Connected.RemoveListener(OnAuthenticated); #else Connected -= OnAuthenticated; #endif } }
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 } }
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 } }