Smack API User search

放肆的年华 提交于 2019-11-27 07:11:24

问题


I'm try to implement a user search on top of my working Smack-API based jabber client.It can create user using:

AccountManager manager = conn.getAccountManager();
manager.createAccount(usename,password);

However I need to add a functionality that will first search for "existing" user before it creates the account, but I can't find any straightforward way to do it. Anyone can provide me hints?

Thanks.


回答1:


Apparently what's needed is just to catch the error code 409 in the XMPPException, as createAccount throws exception if user exist.




回答2:


Although you don't actually need the functionality you requested any more (according to your own answer), I will answer the original question anyway for future reference.

There is a class called UserSearchManager in Smack that can be used for this purpose.




回答3:


Easiest way is to log in as the user once, without sending presence. In general, we try to find all of the ways you could answer this question without having the ability to log in as the user, and eliminate them, in order to help prevent spim.



来源:https://stackoverflow.com/questions/6931100/smack-api-user-search

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!