const int port = 8888; //Can use 80, 8080, 8888, or possibly 443 (make sure to change in client) //25.4.47.197 static void Main(string[] args) { listener = new HttpListener(); listener.Prefixes.Add("http://*:" + port + "/"); //add IP of your website to link to gold purchase OR leave blank and create your own hard-coded website! listener.Start(); //Server will freak out if you don't have admin permissions listen = new Thread(ListenerCallback); listen.Start(); for (var i = 0; i < workers.Length; i++) { workers[i] = new Thread(Worker); workers[i].Start(); } Console.CancelKeyPress += (sender, e) => { Console.WriteLine("Terminating..."); listener.Stop(); while (contextQueue.Count > 0) { Thread.Sleep(100); } Environment.Exit(0); }; Console.ForegroundColor = ConsoleColor.Green; Console.Title = "Database Server"; Console.WriteLine("Connection Successful at Port " + port + "."); XmlDatas.behaviors = false; XmlDatas.DoSomething(); Thread.CurrentThread.Join(); }
static void Main(string[] args) { listener = new HttpListener(); listener.Prefixes.Add("http://*:" + port + "/"); listener.Start(); listen = new Thread(ListenerCallback); listen.Start(); for (var i = 0; i < workers.Length; i++) { workers[i] = new Thread(Worker); workers[i].Start(); } Console.CancelKeyPress += (sender, e) => { Console.WriteLine("Terminating..."); listener.Stop(); while (contextQueue.Count > 0) { Thread.Sleep(100); } Environment.Exit(0); }; Console.WriteLine("Listening at port " + port + "..."); XmlDatas.behaviors = false; XmlDatas.DoSomething(); Thread.CurrentThread.Join(); }
static string BaseModDir = Environment.ExpandEnvironmentVariables("%USERPROFILE%" + ds + "RotMG Server Mods"); //Located in your user folder //For example: BaseModDir, for me, would be: C:\Users\User\RotMG Server Mods //The folder for this server's mods specifically would be: C:\Users\User\RotMG Server Mods\Private Server public static void InitMods(bool behaviors) { string mods = CheckFiles(); FileStream modIdFs = File.OpenRead(mods + ds + "ModIds.data"); using (var rdr = new BinaryReader(modIdFs)) { try { int count = rdr.ReadInt32(); for (int i = 0; i < count; i++) { string name = rdr.ReadString(); short type = rdr.ReadInt16(); XmlDatas.ItemIds.Add(name, type); XmlDatas.UsedIds.Add(type); } } catch { } } foreach (var dir in Directory.GetDirectories(mods)) { foreach (var xml in Directory.GetFiles(dir, "*.xml")) { FileStream fs = File.OpenRead(xml); XmlDatas.ExtraXml.Add(XmlDatas.ProcessModXml(File.OpenRead(xml), dir)); fs.Close(); } } File.WriteAllText(mods + ds + "ModIds.data", ""); modIdFs = File.OpenWrite(mods + ds + "ModIds.data"); using (var wtr = new BinaryWriter(modIdFs)) { wtr.Write(XmlDatas.ItemIds.Count); foreach (var i in XmlDatas.ItemIds) { wtr.Write(i.Key); wtr.Write(i.Value); } } modIdFs.Close(); }
private static void Main(string[] args) { XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net_server.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; Settings = new SimpleSettings("server"); Database = new Database(); GameData = new XmlDatas(); InstanceId = Guid.NewGuid().ToString(); Console.CancelKeyPress += (sender, e) => e.Cancel = true; var port = Settings.GetValue <int>("port", "8888"); if (RunPreCheck(port)) { listener = new HttpListener(); listener.Prefixes.Add($"http://*:{port}/"); listener.Start(); listener.BeginGetContext(ListenerCallback, null); logger.Info($"Listening at port {port}..."); } else { logger.Error($"Port {port} is occupied. Can't start listening...\nPress ESC to exit."); } while (Console.ReadKey(true).Key != ConsoleKey.Escape) { ; } logger.Info("Terminating..."); //To prevent a char/list account in use if //both servers are closed at the same time while (currentRequests.Count > 0) { ; } listener?.Stop(); //GameData.Dispose(); }
private static void Main(string[] args) { XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net_server.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; Settings = new SimpleSettings("server"); Database = new Database(); GameData = new XmlDatas(); InstanceId = Guid.NewGuid().ToString(); Console.CancelKeyPress += (sender, e) => e.Cancel = true; var port = Settings.GetValue<int>("port", "8888"); if (RunPreCheck(port)) { listener = new HttpListener(); listener.Prefixes.Add($"http://*:{port}/"); listener.Start(); listener.BeginGetContext(ListenerCallback, null); logger.Info($"Listening at port {port}..."); } else logger.Error($"Port {port} is occupied. Can't start listening...\nPress ESC to exit."); while (Console.ReadKey(true).Key != ConsoleKey.Escape) ; logger.Info("Terminating..."); //To prevent a char/list account in use if //both servers are closed at the same time while (currentRequests.Count > 0) ; listener?.Stop(); //GameData.Dispose(); }