Ejemplo n.º 1
0
        protected CGameRoom(string name, Server lobby)
        {
            this.name = name;
            this.ownerLobby = lobby;

            gameWorker = new Thread(new ThreadStart(GameWorker));
            gameWorker.IsBackground = true;
            gameWorker.Priority = ThreadPriority.Lowest;
        }
 public LobbyPlayer(string username, NetTunnel tunnel, int bank, Server lobby)
 {
     this.lobby = lobby;
     this.name = username;
     this.bank = bank;
     this.tunnel = tunnel;
     this.tunnel.Identifier = username + " (LobbyPlayer)";
     this.tunnel.OnMessageReceivedEvent += new NetTunnel.OnMessageReceivedCall(tunnel_OnMessageReceivedEvent);
     this.tunnel.OnUnexpectedDisconnectEvent += new NetTunnel.OnUnexpectedDisconnectCall(tunnel_OnUnexpectedDisconnectEvent);
 }
Ejemplo n.º 3
0
        static void Main()
        {
            if (Database.EstablishDatabaseConnection() == false)
            {
                Logger.Log(LogType.Error, "MySQL could not connect");
                return;
            }

            Database.CleanInactiveUsers();

            Server server = new Server(Properties.Settings.Default.serverport);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new ManagerWindow(server));
        }
        public ManagerWindow(Server server)
        {
            InitializeComponent();

            this.server = server;
            this.server.OnChatEvent += new Server.OnChatCall(server_OnChatEvent);

            Logger.LogTextBox = this.txtLog;

            string hostName = Dns.GetHostName();
            txtServerInfo.Text += "Host Name: " + hostName + "\r\n";

            foreach (IPAddress i in Dns.GetHostAddresses(hostName))
            {
                txtServerInfo.Text += "IP: " + i.ToString() + "\r\n";
            }

            txtServerInfo.Text += "LocalEndPoint: " + server.LocalEndPoint + "\r\n";
        }
Ejemplo n.º 5
0
        public static LobbyPlayer Login(string username, string password, NetTunnel tunnel, Server lobby)
        {
            CloseReader();

            Logger.Log(LogType.Event, username + " wants to login");
            try
            {
                string query = String.Format(
                    "SELECT * FROM {0} WHERE (Name='{1}' and Password='******')",
                    playerTableName, username, password);

                MySqlCommand cmd = new MySqlCommand(query, dbConnection);
                dbReader = cmd.ExecuteReader();

                if (dbReader.HasRows == false)
                {
                    CloseReader();
                    return null;
                }

                int chips = Properties.Settings.Default.playerinichips;

                if (dbReader.Read())
                    chips = dbReader.GetInt32("Chips");

                CloseReader();

                query = String.Format(
                    "UPDATE {0} SET Active='1' WHERE Name='{1}'",
                    playerTableName, username);

                cmd = new MySqlCommand(query, dbConnection);
                dbReader = cmd.ExecuteReader();
                CloseReader();

                Logger.Log(LogType.Event, username + " has supplied correct credentials");

                return new LobbyPlayer(username, tunnel, chips, lobby);
            }
            catch (Exception ex)
            {
                Logger.Log("During login for " + username, ex);
                return null;
            }
        }