BF2Statistics.Gamespy.ServerListRetrieveSocket.Shutdown C# (CSharp) Method

Shutdown() public method

Shutsdown the underlying sockets
public Shutdown ( ) : void
return void
        public void Shutdown()
        {
            // Stop accepting new connections
            base.IgnoreNewConnections = true;

            // Unregister events so we dont get a shit ton of calls
            MasterClient.OnDisconnect -= MasterClient_OnDisconnect;

            // Disconnected all connected clients
            foreach (MasterClient client in Clients.Values)
                client.Dispose(true);

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

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

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

Usage Example

        /// <summary>
        /// Shutsdown the Master server and socket
        /// </summary>
        public void Shutdown()
        {
            // Discard the poll timer
            PollTimer.Stop();
            PollTimer.Dispose();

            // Shutdown parent
            base.ShutdownSocket();
            MasterTcpServer.Shutdown();

            // Clear servers
            Servers.Clear();

            // Dispose parent objects
            base.Dispose();
        }