无法让成员进入房间 - XMPP
Posted
技术标签:
【中文标题】无法让成员进入房间 - XMPP【英文标题】:Not able to get members in a room - XMPP 【发布时间】:2018-09-20 07:36:48 【问题描述】:我正在获取所有组的名称...
func xmppMUC(_ sender: XMPPMUC, didDiscoverRooms rooms: [Any], forServiceNamed serviceName: String)
if let elements = rooms as? [DDXMLElement]
for element in elements
print("Name: \(String(describing: element.attributeStringValue(forName: "name")))")
print("JID: \(String(describing: element.attributeStringValue(forName: "jid")))")
print("rooms: \(rooms)")
这给出了所有组的组名。现在如何获取每个组中的组成员列表..?
【问题讨论】:
【参考方案1】:首先,您必须创建一个房间并加入它,该房间已经存在,如下所示。
-(void)joinRoom:(NSString *)groupJid
XMPPJID *JID = [XMPPJID jidWithString:groupJid];
_xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:_xmppRoomHS jid:JID];
[_xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];
[_xmppRoom activate:_xmppStream];
[_xmppRoom joinRoomUsingNickname:_userNick history:nil];
[_xmppRoom fetchOwnersList];
[_xmppRoom fetchAdminsList];
[_xmppRoom fetchMembersList];
它将在其委托方法中获取所有成员、管理员和所有者列表
- (void)xmppRoom:(XMPPRoom *)sender didFetchOwnersList:(NSArray *)items
- (void)xmppRoom:(XMPPRoom *)sender didFetchAdminsList:(NSArray *)items
- (void)xmppRoom:(XMPPRoom *)sender didFetchMembersList:(NSArray *)items
【讨论】:
以上是关于无法让成员进入房间 - XMPP的主要内容,如果未能解决你的问题,请参考以下文章
XMPP XEP-0313 Smack Android 获取所有名册成员的最新消息