如何使用iOS XMPP Robbie Hanson库获取成员所在MUC房间的成员列表
我正在使用git上提供的Robby Hanson的XMPP库,我正在尝试实现MUC或群聊天室 我正在使用一个用户创建聊天室,然后尝试加入,而不邀请其他用户。问题是,如果我尝试与另一个用户(而不是房间的创建者)连接,则会出现错误:如何使用iOS XMPP Robbie Hanson库获取成员所在MUC房间的成员列表,ios,objective-c,xmpp,openfire,muc,Ios,Objective C,Xmpp,Openfire,Muc,我正在使用git上提供的Robby Hanson的XMPP库,我正在尝试实现MUC或群聊天室 我正在使用一个用户创建聊天室,然后尝试加入,而不邀请其他用户。问题是,如果我尝试与另一个用户(而不是房间的创建者)连接,则会出现错误: <iq xmlns="jabber:client" type="error" id="A7F05488-4A84-4EC0-8A6C-0F1541690534" from="newroom4@conference.administrator" to="newuse
<iq xmlns="jabber:client" type="error" id="A7F05488-4A84-4EC0-8A6C-0F1541690534" from="newroom4@conference.administrator" to="newuser229@administrator/abdbd1bc"><query xmlns="http://jabber.org/protocol/muc#admin"><item affiliation="member"/></query><error code="403" type="auth"><forbidden xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>
我使用相同的代码创建或加入一个文件室,这就是我评论下一行的原因:
[xmppRoom fetchConfigurationForm]代码>
我还想添加我设置的:
公共休息室:1
主持人:0
成员数目:0
卡宁维特:1
房间密码:无
注册人数:1
坎迪斯科维吉德:1
已启用日志:1
另外,如果我尝试从一个设备发送消息,当我在另一个设备上检索与另一个用户(该用户不是组的创建者/管理员)一起记录的消息时,我会在控制台中使用LOG_LEVEL_VERBOSE看到传入消息,但它不会调用委托方法。
知道为什么不调用委托方法吗?(我确实在.h中添加了XMPPRoomDelegate)
有人能帮我解决这个错误吗?
非常感谢您的耐心和支持 是因为它不遵循XEP0045说明。您应该执行一个实现此方法的类别:
- (void)joinRoomByContact:(Contact *)contact history:(NSXMLElement *)history
{
dispatch_block_t block = ^{ @autoreleasepool {
// Check state and update variables
// <presence to='darkcave@chat.shakespeare.lit/firstwitch'>
// <x xmlns='http://jabber.org/protocol/muc'/>
// <history/>
// <password>passwd</password>
// </x>
// </presence>
NSXMLElement *x = [NSXMLElement elementWithName:@"x" xmlns:XMPPMUCNamespace];
if (history)
{
[x addChild:history];
}
//XMPPPresence *presence = [XMPPPresence presenceWithType:nil to:myRoomJID];
XMPPElement * presence = [[XMPPElement alloc] initWithName:@"presence"];
[presence addAttributeWithName:@"to" stringValue:[NSString stringWithFormat:@"%@/%@",roomJID.bare,contact.name]];
[presence addAttributeWithName:@"from" stringValue:contact.jid];
[presence addChild:x];
[xmppStream sendElement:presence];
state |= (1 << 3);
}};
if (dispatch_get_specific(moduleQueueTag))
block();
else
dispatch_async(moduleQueue, block);
}
-(void)joinRoomByContact:(Contact*)联系人历史记录:(NSXMLElement*)历史记录
{
dispatch_block_t block=^{@autoreleasepool{
//检查状态并更新变量
//
//
//
//passwd
//
//
NSXMLElement*x=[NSXMLElement elementWithName:@“x”xmlns:XMPPMUCNamespace];
国际单项体育联合会(历史)
{
[x addChild:历史];
}
//XMPPPresence*presence=[XMPPPresence-presenceWithType:nil to:myRoomJID];
XMPPElement*presence=[[XMPPElement alloc]initWithName:@“presence”];
[presence addAttributeWithName:@“to”stringValue:[NSString stringWithFormat:@“%@/%@”,roomJID.bare,contact.name];
[presence addAttributeWithName:@“from”stringValue:contact.jid];
[儿童:x];
[xmppStream sendElement:presence];
状态|=(1)
- (void)joinRoomByContact:(Contact *)contact history:(NSXMLElement *)history
{
dispatch_block_t block = ^{ @autoreleasepool {
// Check state and update variables
// <presence to='darkcave@chat.shakespeare.lit/firstwitch'>
// <x xmlns='http://jabber.org/protocol/muc'/>
// <history/>
// <password>passwd</password>
// </x>
// </presence>
NSXMLElement *x = [NSXMLElement elementWithName:@"x" xmlns:XMPPMUCNamespace];
if (history)
{
[x addChild:history];
}
//XMPPPresence *presence = [XMPPPresence presenceWithType:nil to:myRoomJID];
XMPPElement * presence = [[XMPPElement alloc] initWithName:@"presence"];
[presence addAttributeWithName:@"to" stringValue:[NSString stringWithFormat:@"%@/%@",roomJID.bare,contact.name]];
[presence addAttributeWithName:@"from" stringValue:contact.jid];
[presence addChild:x];
[xmppStream sendElement:presence];
state |= (1 << 3);
}};
if (dispatch_get_specific(moduleQueueTag))
block();
else
dispatch_async(moduleQueue, block);
}