在 XMPP 服务器上创建组



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

任何人请帮助我。

像这样,您可以在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();
    }
}

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

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

最新更新