Я пытаюсь создать приложение для чата, используя XMPPFramework.Я сделал полную настройку соединения.Я также могу сделать чат для одного пользователя.Я также могу создать группу для общения между несколькими пользователями.Моя проблема после создания группы, когда я хочу добавить пользователей в группу, не работает.Вот код, который я использовал.Более того, я не получил никакого вызова этого метода didFetchModeratorsList:
Step-1
#pragma mark --- Create Room
- (void) createChatRoom:(NSString *)groupName{
if (!groupName)
{
return;
}
XMPPRoomMemoryStorage *roomStorage = [[XMPPRoomMemoryStorage alloc] init];
NSString* roomID = [NSString stringWithFormat:@"%@@conference.%@", groupName, CURRENT_HOST_NAME];
XMPPJID * roomJID = [XMPPJID jidWithString:roomID];
XMPPRoom *xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:roomStorage
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:nil
password:nil];
[self performSelector:@selector(ConfigureNewRoom:) withObject:nil afterDelay:3];
}
Step-2
#pragma mark --- addMemberInChatRoom
- (void) addMemberInChatRoom:(NSString*)roomName :(NSArray*)memberId{
NSLog(@"roomName: %@", roomName);
NSLog(@"memberId: %@", memberId);
XMPPRoomMemoryStorage *roomStorage = [[XMPPRoomMemoryStorage alloc] init];
NSString* roomID = [NSString stringWithFormat:@"%@@conference.%@", roomName, CURRENT_HOST_NAME];
XMPPJID * roomJID = [XMPPJID jidWithString:roomID];
XMPPRoom *xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:roomStorage
jid:roomJID
dispatchQueue:dispatch_get_main_queue()];
[xmppRoom activate:xmppStream];
[xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];
[xmppRoom joinRoomUsingNickname:xmppStream.myJID.user
history:nil
password:nil];
[self performSelector:@selector(ConfigureNewRoom:) withObject:nil afterDelay:1];
[xmppRoom inviteUsers:memberId withMessage:@"join this room"];
}
Step-3
#pragma mark --- This fuction is used configure new
- (void)ConfigureNewRoom:(XMPPRoom *)xmppRoom
{
[xmppRoom configureRoomUsingOptions:nil];
[xmppRoom fetchConfigurationForm];
//[xmppRoom fetchBanList];
[xmppRoom fetchMembersList];
//[xmppRoom fetchModeratorsList];
}
Step-4
- (void)xmppRoom:(XMPPRoom *)sender didFetchModeratorsList:(NSArray *)items
{
NSLog(@"%@: %@ --- %@", THIS_FILE, THIS_METHOD, sender.roomJID.bare);
}