我正在开发iOS中的聊天应用程序并使用openfire xmpp服务器?我试图阻止用户使用XEP-0191:阻止命令,但结果出错。
错误xmlns =" jabber:client"类型="取消"代码=" 503" service-unavailable xmlns =" urn:ietf:params:xml:ns:xmpp-stanzas"
答案 0 :(得分:1)
据我所知openfier不支持阻止用户使用 XEP-0191 。您需要实施 XEP-0016 隐私列表。 所以你必须使用创建privacylist 这种方法。
- (void)setListWithName:(NSString *)privacyListName items:(NSArray *)items fromUser:(NSString *)user
您可以使用以下方法将其激活
- (void)setActiveListName:(NSString *)privacyListName;
请参阅
有关隐私列表的详细信息,请按照
进行操作<强> XEP-0016 强>
答案 1 :(得分:0)
这适合我。
XMPPPrivacy * xmppPrivacy =[[XMPPPrivacy alloc] initWithDispatchQueue:dispatch_get_main_queue()];
[xmppPrivacy activate:[XmppGlobalClass sharedInstance].xmppStream];
[xmppPrivacy addDelegate:self delegateQueue:dispatch_get_main_queue()];
NSMutableArray * arraypriv = [[NSMutableArray alloc]init];
NSMutableDictionary * privdict = [[NSMutableDictionary alloc] init];
[privdict setValue:@"deny" forKey:@"action"];
[privdict setValue:jid forKey:@"jid"];
[arraypriv addObject:privdict];
NSXMLElement *privacyElement;
NSMutableArray *arrayPrivacy = [[NSMutableArray alloc] init];
privacyElement = [XMPPPrivacy privacyItemWithType:@"jid"
value:[NSString stringWithFormat:@"%@@%@",[arraypriv
valueForKey:@"jid"],domainName] action:[NSString stringWithFormat:@"%@",[arraypriv valueForKey:@"action"]] order:0];
[arrayPrivacy addObject:privacyElement];
[XMPPPrivacy blockIQs:privacyElement];
[XMPPPrivacy blockMessages:privacyElement];
[XMPPPrivacy blockPresenceIn:privacyElement];
[XMPPPrivacy blockPresenceOut:privacyElement];
[xmppPrivacy setListWithName:@"public" items:arrayPrivacy];
[xmppPrivacy setActiveListName:@"public"];
然后您将在委托方法(在XEP-0016中)
中收到被阻止的用户列表- (void)xmppPrivacy:(XMPPPrivacy *)sender didReceiveListWithName:(NSString *)name items:(NSArray *)items;