简体   繁体   中英

XMPP Smack 4.1.0 check is user is already registered

Hi Im using the Smack XMPP library for android.

I have figured out how to connect, login and create a user, but if I try to create an account with a username that already exist, i get a 'conflict' error, then if i change the username and try again, im locked out for about 10 mins, with a "not_acceptable - wait" error.

So how would i check if the username exists before creating an account?

You can use Roster as:

  1. Create a side account.
  2. Add all accounts to the roster of the account created previously.
  3. Check if the username exists with :

     Collection<RosterEntry> re = roster.getEntries(); 

    And then search for the username in "re".

EDIT : Or simply you can use userSearchManager

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM