BF2Statistics.Gamespy.GpcmServer.Shutdown C# (CSharp) Метод

Shutdown() публичный Метод

Shutsdown the ClientManager server and socket
public Shutdown ( ) : void
Результат void
        public void Shutdown()
        {
            // Stop accepting new connections
            base.IgnoreNewConnections = true;

            // Discard the poll timer
            PollTimer.Stop();
            PollTimer.Dispose();

            // Unregister events so we dont get a shit ton of calls
            GpcmClient.OnSuccessfulLogin -= GpcmClient_OnSuccessfulLogin;
            GpcmClient.OnDisconnect -= GpcmClient_OnDisconnect;

            // Disconnected all connected clients
            Parallel.ForEach(Clients.Values, client => client.Disconnect(9));
            Parallel.ForEach(Processing.Values, client => client.Disconnect(9));

            // Update the database
            try
            {
                // Set everyone's online session to 0
                using (GamespyDatabase Conn = new GamespyDatabase())
                    Conn.Execute("UPDATE accounts SET session=0 WHERE session != 0");
            }
            catch (Exception e)
            {
                Program.ErrorLog.Write("WARNING: [GpcmServer.Shutdown] Failed to update client database: " + e.Message);
            }

            // Update Connected Clients in the Database
            Processing.Clear();
            Clients.Clear();

            // Shutdown the listener socket
            base.ShutdownSocket();

            // Tell the base to dispose all free objects
            base.Dispose();
        }

Usage Example

        /// <summary>
        /// Shutsdown all of the Gamespy Servers
        /// </summary>
        public static void Shutdown()
        {
            // Shutdown Login Servers
            ClientManager.Shutdown();
            SearchProvider.Shutdown();
            MasterServer.Shutdown();
            CDKeyServer.Shutdown();

            // Update status
            bIsRunning = false;

            // Trigger the OnShutdown Event
            Stopped();
        }
All Usage Examples Of BF2Statistics.Gamespy.GpcmServer::Shutdown