1
XMPPJID *servrJID = [XMPPJID jidWithString:@"conference.localhost"];
XMPPIQ *iq = [XMPPIQ iqWithType:@"get" to:servrJID];
[iq addAttributeWithName:@"from" stringValue:[[self xmppStream] myJID].full];
NSXMLElement *query = [NSXMLElement elementWithName:@"query"];
[query addAttributeWithName:@"xmlns" stringValue:@"http://jabber.org/protocol/disco#items"];
[iq addChild:query];
[[self xmppStream] sendElement:iq];

杀死应用程序后,组保持原样,组自动重新加入,

我仍然得到我已经离开/停用的组名

 XMPPJID *roomJID = [XMPPJID jidWithString:Roomjdi];
XMPPRoomMemoryStorage *roomMemoryStorage = [[XMPPRoomMemoryStorage alloc] init];
XMPPRoom *xmppRooms = [[XMPPRoom alloc]
                       initWithRoomStorage:roomMemoryStorage
                       jid:roomJID
                       dispatchQueue:dispatch_get_main_queue()];

[xmppRooms removeDelegate:self delegateQueue:dispatch_get_main_queue()];

[xmppRooms deactivate];
[xmppRooms leaveRoom];

你知道我为什么要再次获得组名吗?

4

1 回答 1

2

如果您先停用房间,它会断开房间与流的连接。出于这个原因,你不能离开房间。所以如果你想离开房间,首先调用离开房间功能然后去激活房间。

例子:

XMPPJID *roomJID = [XMPPJID jidWithString:Roomjdi];
XMPPRoomMemoryStorage *roomMemoryStorage = [[XMPPRoomMemoryStorage alloc] init];
XMPPRoom *xmppRooms = [[XMPPRoom alloc]
                       initWithRoomStorage:roomMemoryStorage
                       jid:roomJID
                       dispatchQueue:dispatch_get_main_queue()];

[xmppRooms removeDelegate:self delegateQueue:dispatch_get_main_queue()];

[xmppRooms leaveRoom];
[xmppRooms deactivate];
于 2017-04-26T06:31:59.283 回答