0
votes

I have established the connection to XMPP server. My question is if there is a Chat Room and new user wants to join, Should I user below Smack class to get it registered?

AccountManager accountManager = AccountManager.getInstance(connection);
accountManager.createAccount(username, password);

Will it create new users to join Room or will it create new user to Main Server. Please help to understand. Thank you!

1

1 Answers

0
votes

Mentioned class and method createAccount create new account on server as you can read from the Github code:

https://github.com/igniterealtime/Smack/blob/master/smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/AccountManager.java

Code:

/**
     * Creates a new account using the specified username and password. The server may
     * require a number of extra account attributes such as an email address and phone
     * number. In that case, Smack will attempt to automatically set all required
     * attributes with blank values, which may or may not be accepted by the server.
     * Therefore, it's recommended to check the required account attributes and to let
     * the end-user populate them with real values instead.
     *
     * @param username the username.
     * @param password the password.
     * @throws XMPPErrorException
     * @throws NoResponseException
     * @throws NotConnectedException
     * @throws InterruptedException
     */
    public void createAccount(Localpart username, String password) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException  {
        // Create a map for all the required attributes, but give them blank values.
        Map<String, String> attributes = new HashMap<>();
        for (String attributeName : getAccountAttributes()) {
            attributes.put(attributeName, "");
        }
        createAccount(username, password, attributes);
    }