예제 #1
0
        public void TryLogin(string username, string password)
        {
            if (Settings.LoginDebug)
            {
                ConsoleUtils.Write(ConsoleMsgType.Info, "User {0} is trying to login\n", username);
            }
            Database        db     = new Database(Server.AuthDbConString);
            MySqlDataReader reader = db.ReaderQuery(
                "SELECT `account_id`, `permission` FROM `login` WHERE `userid` = @userid AND `password` = @password",
                new string[] { "userid", "password" },
                new object[] { username, password }
                );

            if (!reader.HasRows)
            {
                ClientPacketHandler.send_LoginResult(this, Packets.LoginResult.LOGINRESULT_FAIL);
                if (Settings.LoginDebug)
                {
                    ConsoleUtils.Write(ConsoleMsgType.Info, "User {0} login refused (Invalid Credentials)\n", username);
                }
                return;
            }

            reader.Read();
            this.AccountId  = (int)reader["account_id"];
            this.Permission = (byte)reader["permission"];
            this.UserId     = (String)username;

            if (Settings.LoginDebug)
            {
                ConsoleUtils.Write(ConsoleMsgType.Info, "User {0} login accepted\n", username);
            }
            ClientPacketHandler.send_LoginResult(this, Packets.LoginResult.LOGINRESULT_SUCCESS);
        }
예제 #2
0
 private void UserJoinGame(Client client, byte server_index)
 {
     byte[] key = { 0x00, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16 };             // TODO : Generate a key
     ServerPacketHandler.send_ClientJoin(ServerList[server_index], client, key);
     ClientPacketHandler.send_JoinGame(client, key);
 }
예제 #3
0
 public NetworkManager()
 {
     ServerPacketHandler.Start();
     ClientPacketHandler.Start();
 }
예제 #4
0
 internal static void OnUserRequestServerList(Client client)
 {
     ClientPacketHandler.send_ServerList(client, Server.Instance.ServerList);
 }
예제 #5
0
 private void PacketReceived(Client p, PacketStream data)
 {
     ClientPacketHandler.PacketReceived(p, data);
 }