大家好,我正在开发一款IOS聊天应用程序,已经完成了一对一聊天,但在搜索关于群聊的信息后,没有找到如何在xmppframework中创建普通群组的方法。
我已经尝试了以下链接:
但是这些链接都没有给出积极的回应。
在编码方面,我尝试了:
XMPPRoomCoreDataStorage *rosterstorage = [[XMPPRoomCoreDataStorage alloc] init];
XMPPRoom *xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:rosterstorage jid:[XMPPJID jidWithString:@"test@conference.domainName.com/rohit"] dispatchQueue:dispatch_get_main_queue()];
[xmppRoom configureRoomUsingOptions:nil];
[xmppRoom activate:[self xmppStream]];
[xmppRoom addDelegate:self
delegateQueue:dispatch_get_main_queue()];
[xmppRoom inviteUser:[XMPPJID jidWithString:@"abc@domainName.com"] withMessage:@"Hi join room"];
Also this
- (void)createOrEnterRoom:(NSString *)roomName
{
//here we enter a room, or if the room does not yet exist, this method creates it
//per XMPP documentation: "If the room does not yet exist, the service SHOULD create the room"
//this method accepts an argument which is what you would baptize the room you wish created
XMPPPresence *presence = [XMPPPresence presence];
NSString *room = [roomName stringByAppendingString:@"@conference.domain.com"];
[presence addAttributeWithName:@"to" stringValue:room];
NSXMLElement *x = [NSXMLElement elementWithName:@"x" xmlns:@"http://jabber.org/protocol/muc"];
NSXMLElement *history = [NSXMLElement elementWithName:@"history"];
[history addAttributeWithName:@"maxstanzas" stringValue:@"50"];
[x addChild:history];
[presence addChild:x];
[[self xmppStream] sendElement:presence];
}
最后一个是
-(void)createGroup
{
@try {
NSString *username=@"user_3";//[self.userDefault valueForKey:@"userid"];
NSXMLElement *presenceElement=[NSXMLElement elementWithName:@"presence"];
[presenceElement addAttributeWithName:@"type" stringValue:@"groupchat"];
[presenceElement addAttributeWithName:@"from" stringValue:[NSString stringWithFormat:@"%@%@",username,HostName]];
[presenceElement addAttributeWithName:@"to" stringValue:[NSString stringWithFormat:@"testGroup@conference.%@/%@",HostName,username]];
NSXMLElement *xElement=[NSXMLElement elementWithName:@"x" xmlns:@"http://jabber.org/protocol/muc"];
NSXMLElement *historyElement=[NSXMLElement elementWithName:@"history"];
[xElement addChild:historyElement];
[presenceElement addChild:xElement];
[self.xmppStream sendElement:presenceElement];
}
@catch (NSException *exception) {
}
}
请问有人能告诉我如何解决这个问题吗?如果需要在ejjabered配置中进行额外的配置,请也一并告知。