Exemple #1
0
        /// <summary>
        /// Starts the game auth server.
        /// </summary>
        public static void Start()
        {
            SocketEvents socketEvents = new SocketEvents();
            socketEvents.OnReceive = new BufferEvent(HandlePacket);
            SocketServer gameauth = new SocketServer(socketEvents);
            gameauth.Start(Program.Config.ReadString("IPAddress"), Program.Config.ReadInt32("AuthPort"));

            // thread to clean for login : CHECK if UIDCollection contains the entity id at login (before adding to kernel.clients and before ANSWER_OK)
            new System.Threading.Thread(() =>
                                        {
                                            while (true)
                                            {
                                                try
                                                {
                                                    int failed;
                                                    UIDCollection.TryForeachAction((key1, time) =>
                                                                                   {
                                                                                   	try
                                                                                   	{
                                                                                   		if (DateTime.Now >= time)
                                                                                   		{
                                                                                   			int tries = 0;
                                                                                   			while (!UIDCollection.TryRemove(key1) && tries <= 3)
                                                                                   			{
                                                                                   				tries++;
                                                                                   				System.Threading.Thread.Sleep(20);
                                                                                   			}
                                                                                   		}
                                                                                   	}
                                                                                   	catch { }
                                                                                   }, out failed);
                                                    if (failed > 0)
                                                        Console.WriteLine("{0} failed to be removed from the login queue.", failed);
                                                }
                                                catch { }
                                                System.Threading.Thread.Sleep(25000);
                                            }
                                        }).Start();
        }
Exemple #2
0
 /// <summary>
 /// Begins the server.
 /// </summary>
 /// <param name="sockEvents">The socket events.</param>
 /// <param name="port">The port.</param>
 private static void BeginServer(SocketEvents sockEvents, int port)
 {
     AllowConnections = true;
     SocketServer server = new SocketServer(sockEvents);
     server.Start(config.ReadString("IPAddress"), port);
 }