我正在使用iOS xmppframework。 我想在需要时获得聊天记录。这样有一个按钮,当点击按钮时,每次都会收到20条历史消息。
如果我有100条历史消息,我单击该按钮5次,然后我将获得所有历史消息。
[xmppRoom1 joinRoomUsingNickname:@"myNickname" history:history password:nil];
此方法只能使用一次。
答案 0 :(得分:3)
发送历史记录无 和alos在openfire中更新 打开你的openfire网址然后点击群聊>群聊设置>你的小组>历史背景
XMPPRoomMemoryStorage *roomStorage = [[XMPPRoomMemoryStorage alloc] init];
XMPPJID *roomJID = [XMPPJID jidWithString:[NSString stringWithFormat:@"%@@conference.51.101.97.21",groupName]];
XMPPRoom *xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:roomStorage
jid:roomJID
dispatchQueue:dispatch_get_main_queue()];
[xmppRoom activate:xmppStream];
[xmppRoom addDelegate:self
delegateQueue:dispatch_get_main_queue()];
[xmppRoom joinRoomUsingNickname:xmppStream.myJID.user
history:nil
password:nil];
答案 1 :(得分:1)
我使用这种方法,但可以收到任何东西。
NSXMLElement *history = [[NSXMLElement alloc] initWithName:@"history"];
[history addAttributeWithName:@"maxstanzas" stringValue:@"5"];
NSXMLElement *x = [NSXMLElement elementWithName:@"x" xmlns:XMPPMUCNamespace];
if (history)
{
[x addChild:history];
}
XMPPPresence *presence = [XMPPPresence presenceWithType:nil to:xmppRoom1.myRoomJID];
[presence addChild:x];
[xmppStream sendElement:presence];
发送和接收的消息:
SEND:
<presence to="ios@conference.192.168.1.67/myNickname”>
<x xmlns="http://jabber.org/protocol/muc”>
<history maxstanzas="5”/>
</x>
<x xmlns="vcard-temp:x:update"><photo/></x>
<c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="https://github.com/robbiehanson/XMPPFramework" ver="VyOFcFX6+YNmKssVXSBKGFP0BS4=“/>
</presence>
RECV:
<presence xmlns="jabber:client" from="ios@conference.192.168.1.67/myNickname" to="test1@192.168.1.67/14392264591434445057383183”>
<x xmlns="vcard-temp:x:update"><photo/></x>
<c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="https://github.com/robbiehanson/XMPPFramework" ver="VyOFcFX6+YNmKssVXSBKGFP0BS4=“/>
<x xmlns="http://jabber.org/protocol/muc#user”>
<item jid="test1@192.168.1.67/14392264591434445057383183" affiliation="owner" role="moderator"/><status code="110”/>
</x></presence>