gpt4 book ai didi

android - 在 XMPP 服务器上创建组

转载 作者:行者123 更新时间:2023-11-29 16:10:47 25 4
gpt4 key购买 nike

我正在使用 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");

//设置配置函数

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

}

关于android - 在 XMPP 服务器上创建组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13599529/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com