在XMPP服务器上创建组

时间:2012-11-28 07:00:43

标签: android xmpp openfire smack

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

任何人都可以帮助我。

3 个答案:

答案 0 :(得分: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();
    }

}

答案 1 :(得分:0)

尝试为每个组创建持久的多用户聊天(MUC:http://xmpp.org/extensions/xep-0045.html)空间。您将能够向该组中的每个人发送消息,这非常有用。

答案 2 :(得分:0)

试试QuickBlox.com他们也有一个示例程序..