Provides an object wrapper for a file that is used to store LogMessage's into. Uses a Multi-Thread safe Queueing system, and provides full Asynchronous writing and flushing
Inheritance: IDisposable
        static GamespyEmulator()
        {
            // Create our log file
            DebugLog = new LogWriter(Path.Combine(Program.RootPath, "Logs", "GamespyDebug.log"));

            // Register for events
            GpcmServer.OnClientsUpdate += (s, e) => OnClientsUpdate(s, e);
            MasterServer.OnServerlistUpdate += (s, e) => OnServerlistUpdate(s, e);
        }
        /// <summary>
        /// Creates a new instance of CDKeyServer
        /// </summary>
        /// <param name="DebugLog">The GamespyDebug.log logwriter object</param>
        public CDKeyServer(LogWriter DebugLog)
            : base(29910, 4)
        {
            // Debugging
            this.DebugLog = DebugLog;
            DebugLog.Write("Bound to UDP port: " + Port);

            // Start accepting remote connections
            base.StartAcceptAsync();
        }
示例#3
0
        static void Main(string[] args)
        {
            // Enable application visual styling
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Set Exception Handler
            Application.ThreadException += ExceptionHandler.OnThreadException;
            AppDomain.CurrentDomain.UnhandledException += ExceptionHandler.OnUnhandledException;

            // Create Error Log Writter object
            ErrorLog = new LogWriter(Path.Combine(Application.StartupPath, "Logs", "Error.log"));

            // We only allow 1 instance of this application to run at a time, to prevent all kinds of issues with sockets and such
            // A Mutex will allow us to easily require 1 instance
            bool createdNew = true;
            using (Mutex mutex = new Mutex(true, "BF2Statistics Control Center", out createdNew))
            {
                if (createdNew)
                {
                    // Load the main form!
                    Application.Run(new MainForm());
                }
                else
                {
                    // Alert the user
                    MessageBox.Show(
                        "BF2Statistics Control Center is already running. Only one instance of this application can run at a time.",
                        "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning
                    );
                }
            }
        }
        public MasterServer(ref int Port, LogWriter DebugLog)
            : base(27900, MaxConnections)
        {
            // Debugging
            this.DebugLog = DebugLog;
            DebugLog.Write("Bound to UDP port: " + Port);

            // === Start Server List Retrieve Tcp Socket
            Port = 28910;
            DebugLog.Write("Starting Server List Retrieve Socket");
            MasterTcpServer = new ServerListRetrieveSocket();
            DebugLog.Write("Bound to TCP port: " + Port);

            // Start accepting
            base.StartAcceptAsync();

            // Setup timer. Remove servers who havent ping'd since ServerTTL
            PollTimer = new Timer(5000);
            PollTimer.Elapsed += (s, e) => CheckServers();
            PollTimer.Start();
        }
示例#5
0
        /// <summary>
        /// Static constructor
        /// </summary>
        static HttpServer()
        {
            // Create our Server and Access logs
            AspStatsLog = new LogWriter(Path.Combine(Program.RootPath, "Logs", "AspServer.log"));
            HttpAccessLog = new LogWriter(Path.Combine(Program.RootPath, "Logs", "AspAccess.log"), true);

            // Get a list of all our local IP addresses
            LocalIPs = Dns.GetHostEntry(Dns.GetHostName()).AddressList.ToList();

            // Create our conenction pool
            ConnectionPool = new SemaphoreSlim(50, 50);

            // Create our HttpListener instance
            CreateHttpListener();

            // Create our RazorEngine service
            CreateRazorService();

            // Try and clear any old cache files
            ClearRazorCache();

            // Set the Model type once to keep things speedy
            ModelType = typeof(BF2PageModel);
        }