Пример #1
0
        private static void Initalizing()
        {
            AuthServerClass = new AuthServerClass(AuthPoint);
            Database        = new AuthServerDatabase();

            //
            AuthServerRouter.AddHandler <AuthLogonChallenge>(AuthCMD.CMD_AUTH_LOGON_CHALLENGE,
                                                             AuthServerHandler.OnAuthLogonChallenge);
            AuthServerRouter.AddHandler <AuthLogonProof>(AuthCMD.CMD_AUTH_LOGON_PROOF,
                                                         AuthServerHandler.OnAuthLogonProof);
            AuthServerRouter.AddHandler(AuthCMD.CMD_AUTH_REALMLIST, AuthServerHandler.OnAuthRealmList);
        }
Пример #2
0
        private void OnPacket(byte[] data)
        {
            short opcode = BitConverter.ToInt16(data, 0);

            try
            {
                AuthCMD code = (AuthCMD)opcode;
                AuthServerRouter.CallHandler(this, code, data);
            }
            catch (Exception e)
            {
                var trace = new StackTrace(e, true);
                Log.Print(LogType.Error, $"{e.Message}: {e.Source}\n{trace.GetFrame(trace.FrameCount - 1).GetFileName()}:{trace.GetFrame(trace.FrameCount - 1).GetFileLineNumber()}");
                DumpPacket(data, this);
            }
        }
Пример #3
0
        private static void Main()
        {
            var time      = Time.GetMsTime();
            var authPoint = new IPEndPoint(IPAddress.Any, 3724);

            bool quitNow = false;

            Console.Title = $"{Assembly.GetExecutingAssembly().GetName().Name} v{Assembly.GetExecutingAssembly().GetName().Version}";

            Log.Print(LogType.AuthServer, $"Version {Assembly.GetExecutingAssembly().GetName().Version}");
            Log.Print(LogType.AuthServer, $"Running on .NET Framework Version {Environment.Version}");

            // ReSharper disable once UnusedVariable
            var authServerClass = new AuthServerClass(authPoint);

            Database = new AuthServerDatabase();

            //
            AuthServerRouter.AddHandler <AuthLogonChallenge>(AuthCMD.CMD_AUTH_LOGON_CHALLENGE, AuthServerHandler.OnAuthLogonChallenge);
            AuthServerRouter.AddHandler <AuthLogonProof>(AuthCMD.CMD_AUTH_LOGON_PROOF, AuthServerHandler.OnAuthLogonProof);
            AuthServerRouter.AddHandler(AuthCMD.CMD_AUTH_REALMLIST, AuthServerHandler.OnAuthRealmList);

            Log.Print(LogType.AuthServer,
                      $"Successfully started in {Time.GetMsTimeDiff(time, Time.GetMsTime()) / 1000}s");

            // Commands
            while (!quitNow)
            {
                var command = Console.ReadLine();
                switch (command)
                {
                case "/db":
                case "db":
                    // ReSharper disable once ObjectCreationAsStatement
                    new DatabaseManager();
                    Log.Print(LogType.Console, "Database recreated.");
                    break;

                case "/gc":
                case "gc":
                    GC.Collect();
                    Log.Print(LogType.Console,
                              $"Total Memory: {Convert.ToSingle(GC.GetTotalMemory(false) / 1024 / 1024)}MB");
                    break;

                case "/q":
                case "q":
                    quitNow = true;
                    break;

                case "/help":
                case "help":
                case "/?":
                case "?":
                    PrintHelp();
                    Console.WriteLine();
                    break;

                default:
                    Log.Print(LogType.Debug, $"Unknown Command: {command}");
                    break;
                }
            }
        }