2012-11-28 100 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(); 
    } 

}