本文介绍了如何在smack 4.1 beta2中创建持久的muc房间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从asmack迁移到smack 4.1 beta2.创建的muc房间不再持久.

migrated from asmack to smack 4.1 beta2.The muc rooms created are no longer persistent.

MultiUserChatManager mucm=MultiUserChatManager.getInstanceFor(connection);
muc=mucm.getMultiUserChat(groupid+"@conference.localhost");
DiscussionHistory histroy=new DiscussionHistory();
histroy.setMaxStanzas(10);
muc.createOrJoin(username,null,histroy,SmackConfiguration.getDefaultPacketReplyTimeout());
muc.nextMessage();

使用gajim创建时,房间是永久性的.

when created with gajim, the rooms are persistent.

这是我们之前使用的代码.默认情况下,聊天室是持久性的,

EDIT : Here is code we used earlier. By default the chat rooms were persistent,

muc = new MultiUserChat(connection, groupid+"@conference.localhost");

if(!muc.isJoined())
{
DiscussionHistory histroy=new DiscussionHistory();
histroy.setMaxStanzas(10);
muc.join(username,null,histroy,SmackConfiguration.getDefaultPacketReplyTimeout());
muc.nextMessage(0);
}

推荐答案

创建房间开始,您需要在MUC配置中将muc#roomconfig_persistentroom设置为true.

You need to set muc#roomconfig_persistentroom to true in the MUC configuration from when creating the room.

MultiuserChat muc = manager.getMultiUserChat("[email protected]");
muc.create("myNick");
// room is now created by locked
Form form = muc.getConfigurationForm();
Form answerForm = form.createAnswerForm();
answerForm.setAnswer("muc#roomconfig_persistentroom", true);
muc.sendConfigurationForm(answerForm);
// sending the configuration form unlocks the room

请注意,并非所有XMPP MUC服务都支持持久房间.有关更多信息,请参见:

Note that not all XMPP MUC services support persistent rooms. For more information see:

  • https://www.igniterealtime.org/builds/smack/dailybuilds/javadoc/org/jivesoftware/smackx/muc/MultiUserChat.html#create(java.lang.String)
  • https://www.igniterealtime.org/builds/smack/dailybuilds/documentation/extensions/muc.html
  • http://xmpp.org/extensions/xep-0045.html#createroom

这篇关于如何在smack 4.1 beta2中创建持久的muc房间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 22:06