public GpcmServer() : base(29900, MaxConnections)
{
// Register for events
GpcmClient.OnSuccessfulLogin += GpcmClient_OnSuccessfulLogin;
GpcmClient.OnDisconnect += GpcmClient_OnDisconnect;
// Setup timer. Every 15 seconds should be sufficient
PollTimer = new System.Timers.Timer(15000);
PollTimer.Elapsed += (s, e) =>
{
// Send keep alive to all connected clients
if (Clients.Count > 0)
Parallel.ForEach(Clients.Values, client => client.SendKeepAlive());
// Disconnect hanging connections
if (Processing.Count > 0)
Parallel.ForEach(Processing.Values, client => CheckTimeout(client));
};
PollTimer.Start();
// Set connection handling
base.ConnectionEnforceMode = EnforceMode.DuringPrepare;
base.FullErrorMessage = "The Login Server is currently full. Please try again later!";
// Begin accepting connections
base.StartAcceptAsync();
}