在openfire服务器上搜索用户

时间:2014-07-11 06:00:14

标签: android

我正在开发一款聊天应用。我需要搜索在服务器上注册的用户。我正在使用以下代码来实现此目的

   UserSearchManager search = new UserSearchManager(conn.getInstance());  

    Form searchForm;
    try {
    searchForm = search.getSearchForm("search."+conn.getInstance().getServiceName());

    Form answerForm = searchForm.createAnswerForm();  

    answerForm.setAnswer("Username", true);  

    answerForm.setAnswer("search","anurag");  
    ReportedData data = search.getSearchResults(answerForm,"search."+conn.getInstance().getServiceName());  

if(data.getRows() != null)
    {
         //Toast.makeText(this,"Username Exists",Toast.LENGTH_SHORT).show();

    Log.v("user","exits");
        return true;

    }

    /*else
    {
         Toast.makeText(this,"Username Available",Toast.LENGTH_SHORT).show();

    }*/
    } catch (XMPPException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();

        Log.v("Exceptio occured",""+e.getMessage());

    } 
      return false;

Howerver我在这一行上获得了服务不可用(503)异常

searchForm = search.getSearchForm("search."+conn.getInstance().getServiceName());

我还包括以下代码

 provider_manager.addIQProvider("query", "jabber:iq:search", new UserSearch.Provider());

我是否需要在服务器上进行一些配置设置,例如插件等等?

提前致谢。

1 个答案:

答案 0 :(得分:1)

在服务器上添加了search.jar插件,一切顺利......