Новый пользователь в XMPP? - PullRequest
0 голосов
/ 08 июня 2018

Я установил соединение с XMPP-сервером.У меня вопрос: есть ли комната чата и хочет ли присоединиться новый пользователь? Должен ли я зарегистрироваться в классе Smack, чтобы зарегистрировать его?

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

Будет ли он создавать новых пользователей для присоединения к Room или он будет создавать новых пользователей?на главный сервер.Пожалуйста, помогите понять.Спасибо!

1 Ответ

0 голосов
/ 08 июня 2018

Упомянутый класс и метод createAccount создайте новую учетную запись на сервере, как вы можете прочитать из кода Github:

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

Код:

/**
     * 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);
    }
...