Beispiel #1
0
        public static void attemptLogin(string Username, string Password, Packets pH)
        {
            string[] Data = Database.runReadRowStrings("SELECT id,name,access,level,hair_id,password,salt FROM users WHERE name = '" + Username + "'");
            if (Data.Length > 0)
            {
                try
                {
                    User userInfo = new User();
                    userInfo.userID = int.Parse(Data[0]);
                    userInfo.Username = Data[1];
                    userInfo.Access = int.Parse(Data[2]);
                    userInfo.Level = int.Parse(Data[3]);
                    userInfo.HairID = int.Parse(Data[4]);
                    userInfo.connectionID = pH.Connection.connectionID;

                    userSession Session = new userSession(pH.Connection, userInfo);
                    pH.Connection.Session = Session;

                    try { _Sessions.Add(userInfo.userID, Session); }
                    catch
                    {
                        _Sessions.Remove(userInfo.userID);
                        _Sessions.Add(userInfo.userID, Session);
                    }

                    pH.Connection.sendMessage("%xt%loginResponse%-1%true%" + userInfo.userID + "%" + userInfo.Username + "%" + Settings.server_motd + "%1262809466137%sNews=" + Settings.client_news + ",sMap=" + Settings.client_map + ",sBook=" + Settings.client_book + "%");
                }
                catch
                {
                    Logging.logWarning("Disconnected user because another user with same id is already logged in.");
                    Sockets.endConnection(pH.Connection, pH.Connection.Session.userInfo.roomID);
                }
            }
            else
            {
                Logging.logWarning("Disconnected user because of no data.");
                Sockets.endConnection(pH.Connection, pH.Connection.Session.userInfo.roomID);
            }
        }
Beispiel #2
0
 public userSession(userManager Connection, User userInfo)
 {
     this.Connection = Connection;
     this.userInfo = userInfo;
 }