Server: ejabberd2 XMPP: smack 3.3.1
The goal is to design a chat engine. The user, by entering a username should be able to find out if the entered username is registered on the server.
The Smack Javadocs can be found here
I want to find if a username already exists on the server. The code that I have used and its respective error that I got are given below.
UserSearchManager search = new UserSearchManager(connection);
Form searchForm = search.getSearchForm("search."+connection.getServiceName());
Form answerForm = searchForm.createAnswerForm();
answerForm.setAnswer("Username", true);
answerForm.setAnswer("search", name);
ReportedData data = search.getSearchResults(answerForm,"search."+connection.getServiceName());
The above code outputs the following error:
service-unavailable(503)
at org.jivesoftware.smackx.search.UserSearch.getSearchForm(UserSearch.java:84)
at org.jivesoftware.smackx.search.UserSearchManager.getSearchForm(UserSearchManager.java:73)
at com.phanism.www.XmppConnect.searchUser(XmppConnect.java:74)
at com.phanism.www.XmppConnect.main(XmppConnect.java:97)
You have not set the username you want to search.
erSearchManager search = new UserSearchManager(connection);
Form searchForm = search.getSearchForm("search."+connection.getServiceName());
Form answerForm = searchForm.createAnswerForm();
answerForm.setAnswer("Username", true);
answerForm.setAnswer("search", name);//Here username must be added name replace by "amith"
Then it will work.. :)
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.