コード例 #1
0
        /// <summary>
        /// Terminate the listeners
        /// </summary>
        private void EndListening()
        {
            if (listening)
            {
                MasterServer.Log("Shutting down sockets...");
                listening = false;

                // Create list of active listen ports
                List <int> listenPorts = new List <int>(queryListeners.Keys);

                // Unbind listen ports in order
                foreach (int listenPort in listenPorts)
                {
                    UnBind(listenPort);
                }

                // Abort any remaining connections which were not terminated by the listeners (shouldn't be any but it's best to make sure!
                ConnectionManager.AbortAll();

                try
                {
                    if (webServer != null)
                    {
                        webServer.EndListening();
                    }
                }
                catch { }
            }
        }
コード例 #2
0
        /// <summary>
        /// Shut down this listener and all child threads
        /// </summary>
        public void Shutdown()
        {
            aborted = true;

            this.serverList     = null;
            this.geoIP          = null;
            this.cdKeyValidator = null;
            this.gameStats      = null;
            this.md5Manager     = null;
            this.banManager     = null;

            if (listenThread != null)
            {
                // Try to close the listen socket
                if (listenSocket != null)
                {
                    try
                    {
                        listenSocket.Close();
                    }
                    catch { }
                }

                // Try to forcibly abort the listen thread
                listenThread.Abort();
                listenThread.Join();
                listenThread = null;

                MasterServer.Log("[NET] Query listener socket {0} shut down.", endpoint.Port);
            }

            // Abort active connections
            ConnectionManager.AbortAll(endpoint.Port);

            // Release log writer
            ModuleManager.ReleaseModule <IConnectionLogWriter>();
        }