gpt4 book ai didi

ios - XMPPFramework IOS - 实现 MUC

转载 作者:行者123 更新时间:2023-11-29 01:30:04 26 4
gpt4 key购买 nike

引用这个,我正在实现一个群聊配置。

XMPPFramework - Implement Group Chat (MUC)

但是作为参与者而不是主持人,我无法获得成员列表。我已尝试阅读多个堆栈答案,要求实现“muc#roomconfig_getmemberlist”,但 XMPPRoom 的 fetchconfiguration 委托(delegate)未在回调中提供此字段值。

任何人都可以建议实现这个的确切方法以及我如何获取成员列表。

最佳答案

创建xmpp房间使用

/**
This fuction is used to setup room with roomId
*/
-(void)setUpRoom:(NSString *)ChatRoomJID
{
if (!ChatRoomJID)
{
return;
}
// Configure xmppRoom
XMPPRoomMemoryStorage *roomMemoryStorage = [[XMPPRoomMemoryStorage alloc] init];

XMPPJID *roomJID = [XMPPJID jidWithString:ChatRoomJID];

xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:roomMemoryStorage jid:roomJID dispatchQueue:dispatch_get_main_queue()];

[xmppRoom activate:xmppStream];
[xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];

NSXMLElement *history = [NSXMLElement elementWithName:@"history"];
[history addAttributeWithName:@" maxchars" stringValue:@"0"];
[xmppRoom joinRoomUsingNickname:xmppStream.myJID.user
history:history
password:nil];


[self performSelector:@selector(ConfigureNewRoom:) withObject:nil afterDelay:4];

}

/**
This fuction is used configure new
*/
- (void)ConfigureNewRoom:(id)sender
{
[xmppRoom configureRoomUsingOptions:nil];
[xmppRoom fetchConfigurationForm];
[xmppRoom fetchBanList];
[xmppRoom fetchMembersList];
[xmppRoom fetchModeratorsList];

}

创建房间后使用Xmpp房间的Delegate方法

- (void)xmppRoom:(XMPPRoom *)sender occupantDidJoin:(XMPPJID *)occupantJID withPresence:(XMPPPresence *)presence


- (void)xmppRoom:(XMPPRoom *)sender occupantDidLeave:(XMPPJID *)occupantJID withPresence:(XMPPPresence *)presence

使用这两种委托(delegate)方法,您可以轻松维护加入 MUC Room 的用户列表

关于ios - XMPPFramework IOS - 实现 MUC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33545612/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com