static void Main(string[] args) { Out.Header(); AuthServer server = new AuthServer(); server.Initialize("127.0.0.1", 443); ExecuteCommand(); }
static void Main(string[] args) { Out.Initialize(); auth = new AuthServer(); world = new WorldServer(); auth.Initialize(ip, port); ExecuteCommand(); }
private static void Main() { JsonConvert.DefaultSettings = () => new JsonSerializerSettings { Converters = new List <JsonConverter> { new IPEndPointConverter() } }; AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; TaskScheduler.UnobservedTaskException += OnUnobservedTaskException; AuthDatabase.Initialize(); Logger.Info("Starting server..."); AuthServer.Initialize(new Configuration()); AuthServer.Instance.Listen(Config.Instance.Listener); s_apiEventLoopGroup = new MultithreadEventLoopGroup(1); s_apiHost = new ServerBootstrap() .Group(s_apiEventLoopGroup) .Channel <TcpServerSocketChannel>() .Handler(new ActionChannelInitializer <IChannel>(ch => { })) .ChildHandler(new ActionChannelInitializer <IChannel>(ch => { ch.Pipeline.AddLast(new APIServerHandler()); })) .BindAsync(Config.Instance.API.Listener).WaitEx(); Logger.Info("Ready for connections!"); if (Config.Instance.NoobMode) { Logger.Warn("!!! NOOB MODE IS ENABLED! EVERY LOGIN SUCCEEDS AND OVERRIDES ACCOUNT LOGIN DETAILS !!!"); } Console.CancelKeyPress += OnCancelKeyPress; while (true) { var input = Console.ReadLine(); if (input == null) { break; } if (input.Equals("exit", StringComparison.InvariantCultureIgnoreCase) || input.Equals("quit", StringComparison.InvariantCultureIgnoreCase) || input.Equals("stop", StringComparison.InvariantCultureIgnoreCase)) { break; } } Exit(); }
private static void StartServer(ref AuthServer server) { server.Initialize(); server.Start(); GC.Collect(); while (true) { Thread.Sleep(5000); } }
static void Main(string[] args) { var server = new AuthServer(); if (!Debugger.IsAttached) { try { server.Initialize(); server.Start(); GC.Collect(); while (true) { Thread.Sleep(5000); } } catch (Exception e) { server.HandleCrashException(e); } finally { server.Shutdown(); } } else { server.Initialize(); server.Start(); GC.Collect(); while (true) { Thread.Sleep(5000); } } }
static void Main(string[] args) { string packetData = "1510C5122B8697C36C76FCBFA69BFC4300000300EC005201873F7B7800000000"; byte[] packetBytes = Utility.StringToByteArray(packetData); Player testPlayer = new Player(); bool success = ClientUpdate.Instance.Handler(testPlayer, packetBytes); VanaTime.TYPE t = VanaTime.GetInstance().Sync(); uint d = VanaTime.GetInstance().VanaDate; uint month = VanaTime.GetInstance().Month; uint day = VanaTime.GetInstance().Day; uint year = VanaTime.GetInstance().Year; uint hour = VanaTime.GetInstance().Hour; uint minute = VanaTime.GetInstance().Minute; Logger.SetLoggingLevel(LOGGINGLEVEL.ALL); //ConfigHandler.ReadConfigs(); SessionHandler.Initialize(); Logger.Info("Session Handler Initialized"); //// TODO: change how configurations are loaded AuthServer.Initialize("127.0.0.1", 54231); Logger.Info("Auth Server Initialized"); ViewServer.Initialize("127.0.0.1", 54001); Logger.Info("View Server Initialized"); DataServer.Initialize("127.0.0.1", 54230); Logger.Info("Data Server Initialized"); //ActiveSession ass = new ActiveSession() //{ // AccountID = 1234, // PlayerID = 4321, // EndPoint = "127.0.0.1:50301", // CurrentZoneID = 245, // NextZoneID = 245, // Zoning = 0, // SessionHash = "000000000000000000000000000000005CE05DAD" //}; //DBClient.InsertOne(DBREQUESTTYPE.ACTIVESESSION, ass); //DBClient.UpdateOne<ActiveSession>(DBREQUESTTYPE.ACTIVESESSION, a => a.AccountID == 1234, new Dictionary<string, object> { { "CurrentZoneID", 206} }); //DBClient.DeleteOne<ActiveSession>(DBREQUESTTYPE.ACTIVESESSION, a => a.AccountID == 1234); //long updated = DBClient.UpdateOne<Account>(DBREQUESTTYPE.ACCOUNT,a => a.AccountId == 1001,new Dictionary<string, object>() { {"PlayerVars.Test", 5 } } ); //Console.WriteLine(updated); }
static void HandleCommand(string[] cmd) { switch (cmd[0]) { case "rl": ServersManager.Initialize(DatabaseManager.connection); auth.Servers = ServersManager.GetServers(); foreach (AuthClient client in auth.Clients.Values) { foreach (Common.Database.Modeles.Auth.WorldServer s in auth.Servers.Values) { client.Send(new ServerStatusUpdateMessage(new Protocol.Types.GameServerInformations(s.ServerId, s.Status, s.Completion, true, 14))); } } break; case "test": Out.WriteLine("TEST !!!", ConsoleColor.Yellow); break; case "exit": auth.Dispose(); Out.WriteLine("Auth server stopped successfully", ConsoleColor.Cyan); break; case "start": if (auth.Clients != null) { Out.Error("Server already started"); break; } auth.Initialize(ip, port); break; case "world": if (cmd.Length > 1 && cmd[1] == "start") { world = new WorldServer(); } break; default: Out.WriteLine($"Unknown command {cmd[0]}", ConsoleColor.Red); break; } }
public static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler; AppDomain.CurrentDomain.ProcessExit += ProcessExitHandler; foreach (string arg in args) { if (StringCompare.Equals(arg, "-debug")) { _debug = true; } } Logger.Seperator(); Logger.Info("ServTK - [http://servtk.com]"); string arguments = Arguments; if (arguments.Length > 0) { Logger.Info("Running with: {0}", arguments); } Logger.Seperator(); Logger.Info("Loading Configuration Files"); Logger.Log("Auth server IP = " + Config.Settings.Auth.Ip); Logger.Info("Finished Loading Configuration Files"); Logger.Info("Acquiring Authentication Server"); _authServer = (AuthServer)Server.Acquire(typeof(AuthServer)); Logger.Info("Initializing Authentication Server"); _authServer.Initialize(); Logger.Info("Starting Authentication Server"); _authServer.Thread.Start(); Console.ReadLine(); }
private static void Main() { JsonConvert.DefaultSettings = () => new JsonSerializerSettings { Converters = new List <JsonConverter> { new IPEndPointConverter() } }; var jsonlog = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "auth.json"); var logfile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "auth.log"); Log.Logger = new LoggerConfiguration() .WriteTo.File(new JsonFormatter(), jsonlog) .WriteTo.File(logfile) .WriteTo.Console(outputTemplate: "[{Level} {SourceContext}] {Message}{NewLine}{Exception}") .MinimumLevel.Verbose() .CreateLogger(); AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; TaskScheduler.UnobservedTaskException += OnUnobservedTaskException; AuthDatabase.Initialize(); Log.Information("Starting server..."); AuthServer.Initialize(new Configuration()); AuthServer.Instance.Listen(Config.Instance.Listener); s_apiEventLoopGroup = new MultithreadEventLoopGroup(2); s_loginapiHost = new ServerBootstrap() .Group(s_apiEventLoopGroup) .Channel <TcpServerSocketChannel>() .Handler(new ActionChannelInitializer <IChannel>(ch => { })) .ChildHandler(new ActionChannelInitializer <IChannel>(ch => { ch.Pipeline.AddLast(new LoginServerHandler()); })) .BindAsync(Config.Instance.AuthAPI.Listener).WaitEx(); s_apiHost = new ServerBootstrap() .Group(s_apiEventLoopGroup) .Channel <TcpServerSocketChannel>() .Handler(new ActionChannelInitializer <IChannel>(ch => { })) .ChildHandler(new ActionChannelInitializer <IChannel>(ch => { ch.Pipeline.AddLast(new APIServerHandler()); })) .BindAsync(Config.Instance.API.Listener).WaitEx(); Log.Information("Ready for connections!"); if (Config.Instance.NoobMode) { Log.Warning("!!! NOOB MODE IS ENABLED! EVERY LOGIN SUCCEEDS AND OVERRIDES ACCOUNT LOGIN DETAILS !!!"); } Console.CancelKeyPress += OnCancelKeyPress; while (true) { var input = Console.ReadLine(); if (input == null) { break; } if (input.Equals("exit", StringComparison.InvariantCultureIgnoreCase) || input.Equals("quit", StringComparison.InvariantCultureIgnoreCase) || input.Equals("stop", StringComparison.InvariantCultureIgnoreCase)) { break; } } Exit(); }
private static void Main() { JsonConvert.DefaultSettings = () => new JsonSerializerSettings { Converters = new List <JsonConverter> { new IPEndPointConverter() } }; Config <Config> .Initialize("auth.hjson", "NETSPHEREPIRATES_AUTHCONF"); var jsonlog = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "auth.json"); var logfile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "auth.log"); Log.Logger = new LoggerConfiguration() .Destructure.ByTransforming <IPEndPoint>(endPoint => endPoint.ToString()) .Destructure.ByTransforming <EndPoint>(endPoint => endPoint.ToString()) .WriteTo.File(new JsonFormatter(), jsonlog) .WriteTo.File(logfile) .WriteTo.Console(outputTemplate: "[{Level} {SourceContext}] {Message}{NewLine}{Exception}") .MinimumLevel.Debug() .CreateLogger(); AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; TaskScheduler.UnobservedTaskException += OnUnobservedTaskException; try { AuthDatabase.Initialize(Config.Instance.Database.Auth); } catch (DatabaseNotFoundException ex) { Log.Error("Database {Name} not found", ex.Name); Environment.Exit(1); } catch (DatabaseVersionMismatchException ex) { Log.Error("Invalid version. Database={CurrentVersion} Required={RequiredVersion}. Run the DatabaseMigrator to update your database.", ex.CurrentVersion, ex.RequiredVersion); Environment.Exit(1); } Log.Information("Starting server..."); AuthServer.Initialize(new ProudNet.Configuration { SocketListenerThreads = new MultithreadEventLoopGroup(1), SocketWorkerThreads = new MultithreadEventLoopGroup(1), WorkerThread = new SingleThreadEventLoop() }); AuthServer.Instance.Listen(Config.Instance.Listener); s_apiEventLoopGroup = new MultithreadEventLoopGroup(1); s_apiHost = new ServerBootstrap() .Group(s_apiEventLoopGroup) .Channel <TcpServerSocketChannel>() .Handler(new ActionChannelInitializer <IChannel>(ch => { })) .ChildHandler(new ActionChannelInitializer <IChannel>(ch => { ch.Pipeline.AddLast(new APIServerHandler()); })) .BindAsync(Config.Instance.API.Listener).WaitEx(); Log.Information("Ready for connections!"); if (Config.Instance.NoobMode) { Log.Warning("!!! NOOB MODE IS ENABLED! EVERY LOGIN SUCCEEDS AND OVERRIDES ACCOUNT LOGIN DETAILS !!!"); } Console.CancelKeyPress += OnCancelKeyPress; while (true) { var input = Console.ReadLine(); if (input == null) { break; } if (input.Equals("exit", StringComparison.InvariantCultureIgnoreCase) || input.Equals("quit", StringComparison.InvariantCultureIgnoreCase) || input.Equals("stop", StringComparison.InvariantCultureIgnoreCase)) { break; } } Exit(); }