Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the ServerGui class.
        /// </summary>
        /// <param name="server">The server object this instance should store a reference to.</param>
        private ServerGui(GameServer server)
        {
            this.server = server;

            if (this.InvokeRequired)
            {
                this.Invoke((Action)this.InitializeComponent);
            }
            else
            {
                this.InitializeComponent();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates an instance of ServerGui and begins running a standard application method loop,
        /// then returns a reference to the created instance.
        /// </summary>
        /// <param name="server">The server object this instance should store a reference to.</param>
        /// <returns>See summary.</returns>
        public static ServerGui CreateGui(GameServer server)
        {
            ServerGui.gui = new ServerGui(server);
            new Thread(new ThreadStart(ServerGui.Run)).Start();

            // Block until the GUI's handles have been created to prevent
            // invalid cross-thread control access
            while (!ServerGui.gui.Visible)
            {
                Thread.Sleep(1);
            }

            return ServerGui.gui;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the PlayerHandler class.
        /// </summary>
        /// <param name="server">A reference to the server object.</param>
        /// <param name="connection">The TCP client object describing the client's binding to the server.</param>
        public PlayerHandler(GameServer server, NetworkServerHandler connection)
            : base()
        {
            lock (this)
            {
                this.server = server;
                this.Connection = connection;
                this.PlayerHostName = connection.Connection.Client.RemoteEndPoint.ToString();
                this.connectionTimeUTC = DateTime.UtcNow.Ticks;

                this.Id = -1;
                this.PasswordHash = string.Empty;
                this.UserLevel = UserPermissionLevel.Regular;
                this.Inventory = new PlayerInventory();
                this.ObjectsSeen = new Collection<GameObjectBase>();

                new Thread(this.Run).Start();
            }
        }
Exemplo n.º 4
0
        public static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //DatabaseManager databaseManager = ProgramLauncher.GetLogOnInfo(args);
            //if (databaseManager != null)
            {
                GameServer server = new GameServer();

                try
                {
                    Console.SetOut(new StreamWriter("log.txt", true, Encoding.UTF8));
                    Thread.CurrentThread.Name = "Main Server Processing Thread";
                    server.Run(/*null*/);
                }
                catch (Exception e)
                {
                    MessageBox.Show("Error", "FATAL ERROR. Server will now exit.", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, server.ServerGui.RightToLeft == RightToLeft.Yes ? MessageBoxOptions.RtlReading : 0);
                    new ThreadExceptionDialog(e).ShowDialog();
                }
            }
        }