/// <summary> /// Static constructor /// </summary> static ASPServer() { ServerLog = new LogWritter(Path.Combine(MainForm.Root, "Logs", "AspServer.log"), 3000); AccessLog = new LogWritter(Path.Combine(MainForm.Root, "Logs", "AspAccess.log"), 3000); LocalIPs = Dns.GetHostAddresses(Dns.GetHostName()).ToList(); SessionRequests = 0; }
static void Main() { // Set exception Handler Application.ThreadException += new ThreadExceptionEventHandler(ExceptionHandler.OnThreadException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ExceptionHandler.OnUnhandledException); // Create ErrorLog file ErrorLog = new LogWritter(Path.Combine(Application.StartupPath, "Logs", "Error.log")); // Load the main form! Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); }
/// <summary> /// Static constructor /// </summary> static ASPServer() { // Create our Server and Access logs ServerLog = new LogWritter(Path.Combine(Program.RootPath, "Logs", "AspServer.log")); AccessLog = new LogWritter(Path.Combine(Program.RootPath, "Logs", "AspAccess.log"), true); // Get a list of all our local IP addresses LocalIPs = new List<IPAddress>(Dns.GetHostAddresses(Dns.GetHostName())); SessionRequests = 0; // Create our HttpListener instance Listener = new HttpListener(); Listener.Prefixes.Add("http://*/ASP/"); }
/// <summary> /// Constructor. Initializes and Displays the Applications main GUI /// </summary> public MainForm() { InitializeComponent(); // Set instance Instance = this; // Check for needed settings upgrade if (!Config.SettingsUpdated) { Config.Upgrade(); Config.SettingsUpdated = true; Config.Save(); } // If this is the first run, Get client and server install paths if (String.IsNullOrWhiteSpace(Config.ServerPath) || !File.Exists(Path.Combine(Config.ServerPath, "bf2_w32ded.exe"))) { InstallForm IS = new InstallForm(); if (IS.ShowDialog() != DialogResult.OK) { this.Load += new EventHandler(CloseOnStart); return; } } // Make sure documents folder exists if (!Directory.Exists(Paths.DocumentsFolder)) Directory.CreateDirectory(Paths.DocumentsFolder); // Backups folder if(!Directory.Exists(Path.Combine(Paths.DocumentsFolder, "Backups"))) Directory.CreateDirectory(Path.Combine(Paths.DocumentsFolder, "Backups")); // Create ErrorLog file ErrorLog = new LogWritter(Path.Combine(Root, "Logs", "Error.log"), 3000); // Load installed Mods. If there is an error, a messagebox will be displayed, // and the form closed automatically if (!LoadModList()) return; // Set BF2Statistics Install Status SetInstallStatus(); // Get snapshot counts CountSnapshots(); // Check if the server is already running CheckServerProcess(); // Try to access the hosts file DoHOSTSCheck(); // Load Cross Session Settings ParamBox.Text = Config.ClientParams; GlobalServerSettings.Checked = Config.UseGlobalSettings; ShowConsole.Checked = Config.ShowServerConsole; MinimizeConsole.Checked = Config.MinimizeServerConsole; IgnoreAsserts.Checked = Config.ServerIgnoreAsserts; FileMoniter.Checked = Config.ServerFileMoniter; GpcmAddress.Text = (!String.IsNullOrWhiteSpace(Config.LastLoginServerAddress)) ? Config.LastLoginServerAddress : "localhost"; Bf2webAddress.Text = (!String.IsNullOrWhiteSpace(Config.LastStatsServerAddress)) ? Config.LastStatsServerAddress : "localhost"; labelTotalWebRequests.Text = Config.TotalASPRequests.ToString(); // If we dont have a client path, disable the Launch Client button LaunchClientBtn.Enabled = (!String.IsNullOrWhiteSpace(Config.ClientPath) && File.Exists(Path.Combine(Config.ClientPath, "bf2.exe"))); // Register for ASP events ASPServer.Started += new EventHandler(ASPServer_OnStart); ASPServer.Stopped += new EventHandler(ASPServer_OnShutdown); ASPServer.RequestRecieved += new AspRequest(ASPServer_ClientConnected); Snapshot.SnapshotProccessed += new SnapshotProccessed(Snapshot_SnapshotProccessed); ASP.Requests.SnapshotPost.SnapshotReceived += new SnapshotRecieved(SnapshotPost_SnapshotReceived); // Register for Login server events LoginServer.OnStart += new StartupEventHandler(LoginServer_OnStart); LoginServer.OnShutdown += new ShutdownEventHandler(LoginServer_OnShutdown); LoginServer.OnUpdate += new EventHandler(LoginServer_OnUpdate); // Add administrator title to program title bar if (IsAdministrator) this.Text += " (Administrator)"; // Set server tooltips Tipsy.SetToolTip(LoginStatusPic, "Login server is currently offline."); Tipsy.SetToolTip(AspStatusPic, "Asp server is currently offline"); }
static LoginServer() { // Create our log file, and register for events Logger = new LogWritter(Path.Combine(Program.RootPath, "Logs", "LoginServer.log"), true); GpcmServer.OnClientsUpdate += new EventHandler(CmServer_OnUpdate); }