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();
}