如何加入指定消息数的聊天室
How to join a chat room with specified number of messages
目前我正在加入这样的聊天室。
_xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:_roomStorage
jid:roomJID
dispatchQueue:dispatch_get_main_queue()];
[_xmppRoom activate:[self appDelegate].xmppStream];
[_xmppRoom addDelegate:self
delegateQueue:dispatch_get_main_queue()];
NSString *profileId = @"123456";
NSString *myPassword = [[NSUserDefaults standardUserDefaults] stringForKey:@"userPassword"];
[[NSUserDefaults standardUserDefaults] synchronize];
[_xmppRoom joinRoomUsingNickname:profileId history:nil password:myPassword];
我只想检索指定数量的消息作为聊天记录。目前它正在一次检索所有消息,这会导致聊天记录过长的问题。
你能帮帮我吗?
这是我找到的答案。您必须发送一个指定了最大节数的 XML 元素。
这是代码。
XMPPJID *roomJID = [XMPPJID jidWithString:roomID];
_xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:_roomStorage
jid:roomJID
dispatchQueue:dispatch_get_main_queue()];
[_xmppRoom activate:[self appDelegate].xmppStream];
[_xmppRoom addDelegate:self
delegateQueue:dispatch_get_main_queue()];
NSString *profileId = @"123456";
NSString *myPassword = [[NSUserDefaults standardUserDefaults] stringForKey:@"userPassword"];
[[NSUserDefaults standardUserDefaults] synchronize];
NSXMLElement *history = [NSXMLElement elementWithName:@"history"];
[history addAttributeWithName:@"maxstanzas" stringValue:@"10"];
[_xmppRoom joinRoomUsingNickname:profileId history:history password:myPassword];
目前我正在加入这样的聊天室。
_xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:_roomStorage
jid:roomJID
dispatchQueue:dispatch_get_main_queue()];
[_xmppRoom activate:[self appDelegate].xmppStream];
[_xmppRoom addDelegate:self
delegateQueue:dispatch_get_main_queue()];
NSString *profileId = @"123456";
NSString *myPassword = [[NSUserDefaults standardUserDefaults] stringForKey:@"userPassword"];
[[NSUserDefaults standardUserDefaults] synchronize];
[_xmppRoom joinRoomUsingNickname:profileId history:nil password:myPassword];
我只想检索指定数量的消息作为聊天记录。目前它正在一次检索所有消息,这会导致聊天记录过长的问题。
你能帮帮我吗?
这是我找到的答案。您必须发送一个指定了最大节数的 XML 元素。
这是代码。
XMPPJID *roomJID = [XMPPJID jidWithString:roomID];
_xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:_roomStorage
jid:roomJID
dispatchQueue:dispatch_get_main_queue()];
[_xmppRoom activate:[self appDelegate].xmppStream];
[_xmppRoom addDelegate:self
delegateQueue:dispatch_get_main_queue()];
NSString *profileId = @"123456";
NSString *myPassword = [[NSUserDefaults standardUserDefaults] stringForKey:@"userPassword"];
[[NSUserDefaults standardUserDefaults] synchronize];
NSXMLElement *history = [NSXMLElement elementWithName:@"history"];
[history addAttributeWithName:@"maxstanzas" stringValue:@"10"];
[_xmppRoom joinRoomUsingNickname:profileId history:history password:myPassword];