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 am using UserSearch classes found in the Smack library.
- I can connect to the server.
- I can login using a username and password.
- I can add/sign up new users into the server.
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.
Then it will work.. :)