我正在开发使用XMPPFramework的iOS XMPPFramework - 房/聊天消息历史
怎样才能收到邮件的历史加入现有的后室聊天应用程序?
现在我加入到房间是这样的:
XMPPJID *roomJid = [XMPPJID jidWithString:[NSString stringWithFormat:@"%@@conference.%@",systemName,xmppServer]];
xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:[XMPPRoomHybridStorage sharedInstance] jid:roomJid];
[xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];
[xmppRoom activate:xmppStream];
NSXMLElement *history = [NSXMLElement elementWithName:@"history"];
[history addAttributeWithName:@"maxstanzas" stringValue:@"100"];
[xmppRoom joinRoomUsingNickname:user.deviceUUID history:history];
而且我从documentation
读例如根据这个例子,我也想加入房间是这样的:
XMPPJID *roomJid = [XMPPJID jidWithString:[NSString stringWithFormat:@"%@@conference.%@",systemName,xmppServer]];
xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:[XMPPRoomHybridStorage sharedInstance] jid:roomJid];
[xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];
[xmppRoom activate:xmppStream];
NSXMLElement *presence = [NSXMLElement elementWithName:@"presence"];
[presence addAttributeWithName:@"from" stringValue:[NSString stringWithFormat:@"[email protected]%@",xmppServer]];
[presence addAttributeWithName:@"to" stringValue:[NSString stringWithFormat:@"%@@conference.%@/%@",systemName,xmppServer,user.deviceUUID]];
NSXMLElement *x = [NSXMLElement elementWithName:@"x" xmlns:@"http://jabber.org/protocol/muc"];
NSXMLElement *history = [NSXMLElement elementWithName:@"history"];
[history addAttributeWithName:@"maxstanzas" stringValue:@"100"];
[x addChild:history];
[presence addChild:x];
[xmppRoom joinRoomUsingNickname:user.deviceUUID history:presence];
我成功加入会议室,但没有收到以前消息的历史记录。
顺便说一句,如果在室内至少一个用户,我收到所有以前的消息,甚至如果我加入房间,如:
[xmppRoom joinRoomUsingNickname:user.deviceUUID history:nil];
如果所有用户离开房间,然后一些再加入 - 历史空=(
我在做什么错? 我是否需要开启一些设置在服务器端保存历史(如日志记录)?
和一些关于文档示例的问题:
什么意思是“from”参数?这是否意味着我只从用户bob那里询问这个房间的消息历史?如果我想接收所有历史记录(来自任何用户的消息),该怎么办?
什么意思是“id”参数?我没有在文档中找到任何描述。
感谢您的回复,我今天会尝试 – stsmkrv 2015-02-12 08:29:45
让我知道,这对我有用! – Moral 2015-02-12 21:15:57