/// <summary> /// Starts the server. /// </summary> /// <param name="args"></param> public static void Main() { Console.WriteLine("Welcome to DotNetwork."); Console.WriteLine("A fast and lightweight C# emulation game network for the RuneTek engine."); Console.WriteLine("Loading the cache..."); CacheManager.Load(); Console.WriteLine($"Registered {PacketRepository.PACKET_ENCODERS.Count} packet encoder(s)."); Console.WriteLine($"Registered {PacketRepository.PACKET_DECODERS.Count} packet decoder(s)."); Console.WriteLine($"Registered {InterfaceListenerRepository.INTERFACE_LISTENERS.Count} interface listener(s)."); Console.WriteLine("Starting the network..."); NetworkBootstrap.StartNetwork(); Console.WriteLine("Online!"); //To keep the server from closing. while (true) { if (Console.ReadLine().Equals("close")) { break; } } }
/// <summary> /// The entry point of the program, where the program control starts and ends. /// </summary> /// <param name="args">The command-line arguments.</param> public static void Main(string[] args) { Console.WriteLine("Welcome to Quavo C# [" + VERSION + "]!"); Console.WriteLine("Starting the network."); NetworkBootstrap.Start(); Console.WriteLine("Quavo is online!"); Console.ReadLine(); }
void Awake() { Instance = this; //try //{ // LanIP = Dns.GetHostAddresses(Dns.GetHostName()).First(x => x.AddressFamily == AddressFamily.InterNetwork).ToString(); //} //catch (Exception ex) //{ // Debug.Log("Failed to get internal IP :\n" + ex.ToString()); // LanIP = "UNKNOWN"; //} //WanIP = GetIP(); }
public static void Initialize() { ServerStarted = DateTime.Now; Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine(); Console.WriteLine(" ____ __ ________ _____ __"); Console.WriteLine(@" / __ \/ /_ _______/ ____/ |/ / / / /"); Console.WriteLine(" / /_/ / / / / / ___/ __/ / /|_/ / / / / "); Console.WriteLine(" / ____/ / /_/ (__ ) /___/ / / / /_/ / "); Console.WriteLine(@" /_/ /_/\__,_/____/_____/_/ /_/\____/ "); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(" " + PrettyVersion + " <Build " + PrettyBuild + ">"); Console.WriteLine(" http://PlusIndustry.com"); Console.WriteLine(""); Console.Title = "Loading Plus Emulator"; _defaultEncoding = Encoding.Default; Console.WriteLine(""); Console.WriteLine(""); CultureInfo = CultureInfo.CreateSpecificCulture("en-GB"); try { string projectSolutionPath = Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory())); _configuration = new ConfigurationData("./Config/config.ini"); var connectionString = new MySqlConnectionStringBuilder { ConnectionTimeout = 10, Database = GetConfig().data["db.name"], DefaultCommandTimeout = 30, Logging = false, MaximumPoolSize = uint.Parse(GetConfig().data["db.pool.maxsize"]), MinimumPoolSize = uint.Parse(GetConfig().data["db.pool.minsize"]), Password = GetConfig().data["db.password"], Pooling = true, Port = uint.Parse(GetConfig().data["db.port"]), Server = GetConfig().data["db.hostname"], UserID = GetConfig().data["db.username"], AllowZeroDateTime = true, ConvertZeroDateTime = true, SslMode = MySqlSslMode.None }; _manager = new DatabaseManager(connectionString.ToString()); if (!_manager.IsConnected()) { log.Error("Failed to Connect to the specified MySQL server."); Console.ReadKey(true); Environment.Exit(1); return; } log.Info("Connected to Database!"); //Reset our statistics first. using (IQueryAdapter dbClient = GetDatabaseManager().GetQueryReactor()) { dbClient.RunQuery("TRUNCATE `catalog_marketplace_data`"); dbClient.RunQuery("UPDATE `rooms` SET `users_now` = '0' WHERE `users_now` > '0';"); dbClient.RunQuery("UPDATE `users` SET `online` = '0' WHERE `online` = '1'"); dbClient.RunQuery("UPDATE `server_status` SET `users_online` = '0', `loaded_rooms` = '0'"); } //Get the configuration & Game set. _languageManager = new LanguageManager(); _languageManager.Init(); _settingsManager = new SettingsManager(); _settingsManager.Init(); _figureManager = new FigureDataManager(); _figureManager.Init(); //Have our encryption ready. HabboEncryptionV2.Initialize(new RSAKeys()); //Make sure Rcon is connected before we allow clients to Connect. _Rcon = new RconSocket(GetConfig().data["rcon.tcp.bindip"], int.Parse(GetConfig().data["rcon.tcp.port"]), GetConfig().data["rcon.tcp.allowedaddr"].Split(Convert.ToChar(";"))); _game = new Game(); _game.StartGameLoop(); //Accept connections. _bootstrap = new NetworkBootstrap(GetConfig().data["game.tcp.bindip"], int.Parse(GetConfig().data["game.tcp.port"])); _bootstrap.InitAsync().Wait(); TimeSpan TimeUsed = DateTime.Now - ServerStarted; Console.WriteLine(); log.Info("EMULATOR -> READY! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)"); } #pragma warning disable CS0168 // The variable 'e' is declared but never used catch (KeyNotFoundException e) #pragma warning restore CS0168 // The variable 'e' is declared but never used { log.Error("Please check your configuration file - some values appear to be missing."); log.Error("Press any key to shut down ..."); Console.ReadKey(true); Environment.Exit(1); return; } catch (InvalidOperationException e) { log.Error("Failed to initialize PlusEmulator: " + e.Message); log.Error("Press any key to shut down ..."); Console.ReadKey(true); Environment.Exit(1); return; } catch (Exception e) { log.Error("Fatal error during startup: " + e); log.Error("Press a key to exit"); Console.ReadKey(); Environment.Exit(1); } }