2012-11-28 64 views
0

我正在制作一个使用xmpp/openfire的聊天应用程序,并且我想在服务器上创建组,其中服务器上的任何人都可以加入。在XMPP服务器上创建组

任何人都请帮助我一样。

回答

0

尝试QuickBlox.com他们有太多的样本程序..

4

喜欢这种方式,您可以在XMPP服务器创建组

  SmackAndroid.init(SelectMembers.this); 
      MultiUserChat muc = new MultiUserChat(xconnection, GroupName 
        + "@conference.fonechat.in"); 
      muc.create(my_number); 
      setConfig(muc); 
      muc = new MultiUserChat(xconnection, GroupName + "@conference.serverid"); 
      muc.join(my_number); 
      for (int i = 0; i < name.size(); i++) { 
       muc.invite(phone.get(i).toString() + "@fonechat.in", 
         "Meet me in this excellent room"); 

//调用setConfig功能

private void setConfig(MultiUserChat multiUserChat) { 

    try { 
     Form form = multiUserChat.getConfigurationForm(); 
     Form submitForm = form.createAnswerForm(); 
     for (Iterator<FormField> fields = submitForm.getFields(); fields 
       .hasNext();) { 
      FormField field = (FormField) fields.next(); 
      if (!FormField.TYPE_HIDDEN.equals(field.getType()) 
        && field.getVariable() != null) { 
       submitForm.setDefaultAnswer(field.getVariable()); 
      } 
     } 
     submitForm.setAnswer("muc#roomconfig_publicroom", true); 
     submitForm.setAnswer("muc#roomconfig_persistentroom", true); 
     multiUserChat.sendConfigurationForm(submitForm); 
    } catch (Exception e) { 
     e.printStackTrace(); 
    } 

}