Beispiel #1
0
    //Login just checks if a user exist.
    public FailureType login(Client connectingUser)
    {
        //Finds user.
        int index;

        index = users.findIndexByName(connectingUser.Name);

        //Fails if user doesn't exist is already online or if passwords to match.
        if (index == -1)
        {
            return(FailureType.FailedUserDoesNotExist);
        }
        else if (users.ElementAt(index).Online == true)
        {
            return(FailureType.FailedUserAlreadyOnline);
        }
        else if (Client.checkPassword(users.ElementAt(index), connectingUser.Password) == true)
        {
            Console.WriteLine(connectingUser.Name + " did a login check.");
            return(FailureType.Good);
        }
        else
        {
            return(FailureType.FailedUnknownReason);
        }
    }