Exemple #1
0
        public static bool getLoginInfo(string username, out UserLoginInformation user)
        {
            UserLoginInformation loginAttempt = (UserLoginInformation)userLoginColl.FindOne(x => x.username == username);

            user = loginAttempt;
            if (loginAttempt == null)
            {
                return(false);
            }
            return(true);
        }
Exemple #2
0
        //Should later be rewritten so we separate a update and a new entry. For opting the performance
        //Also use Generics/Polymorphism
        #region Setters
        public static void updateLoginInfo(UserLoginInformation update)
        {
            UserLoginInformation loginAttempt = userLoginColl.FindOne(x => x.username == update.username);

            if (loginAttempt == null)
            {
                userLoginColl.Insert(update);
            }
            else
            {
                userLoginColl.Update(update);
            }
        }
Exemple #3
0
        //Right now the peerID and username search makes no sense... Fix later
        //To error check we could later store the peerID -> Username somewhere
        private static void addActiveUser(UserLoginInformation user, int newPeerID)
        {
            ActiveUser newUser = activeUsersColl.FindOne(x => x.username == user.username);

            if (newUser == null)
            {
                activeUsersColl.Insert(new ActiveUser {
                    username = user.username, peerId = newPeerID.ToString()
                });
                //Debug.LogError ("Adding user with ID: " + newPeerID);
            }
            else               //This should never happen
            {
                newUser.peerId = newPeerID.ToString();
                activeUsersColl.Update(newUser);
            }
        }
Exemple #4
0
        private static void incrementLoginCounter(UserLoginInformation user)
        {
            UserInfo info;

            if (getUserData(user.username, out info) == false)
            {
                return;
            }

            int currentLogins;

            if (int.TryParse(info.logins, out currentLogins) == false)
            {
                return;
            }
            info.logins = (currentLogins + 1).ToString();
            updateGameStat(info);
        }
Exemple #5
0
        public static void onPlayerDissconnected(int peerID)
        {
            string     keyID   = peerID.ToString();
            ActiveUser oldUser = activeUsersColl.FindOne(x => x.peerId == keyID);

            if (oldUser != null)
            {
                //Debug.LogError ("Removing for id: " + peerID);
                activeUsersColl.Delete(oldUser.peerId);
                UserLoginInformation savedUser = userLoginColl.FindOne(x => x.username == oldUser.username);
                if (savedUser != null)
                {
                    savedUser.isLoggedIn = false;
                    updateLoginInfo(savedUser);
                }

                UserDataModule.userLogedOut(oldUser.username);
            }
        }
Exemple #6
0
 public static void onUserLogedIn(UserLoginInformation user, int peerID)
 {
     user.isLoggedIn = true;
     updateLoginInfo(user);
     addActiveUser(user, peerID);
 }