【问题标题】:Create Groups on XMPP server在 XMPP 服务器上创建组
【发布时间】:2012-11-28 07:00:42
【问题描述】:

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

任何人都请帮助我。

【问题讨论】:

    标签: android xmpp openfire smack


    【解决方案1】:

    这样你可以在 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");
    

    //设置配置函数

        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();
        }
    
    }
    

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        【解决方案3】:

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

        【讨论】:

          猜你喜欢
          • 2012-02-07
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2014-03-15
          • 2013-09-22
          • 1970-01-01
          • 1970-01-01
          • 2016-01-18
          相关资源
          最近更新 更多