使用 XMPP 创建群聊



我正在创建一个聊天应用程序,我已经进行了一对一的聊天,但无法了解如何创建聊天室和添加人员。

我认为此链接将为您提供必要的信息:http://xmpp.org/extensions/xep-0045.html。

简单来说,在登录到服务器时改变资源允许多个用户隶属于单个登录,即单个登录完成聊天室的工作。

您可以轻松创建群聊群组。使用以下函数创建组

-(void)joinMultiUserChatRoom:(NSString *)RoomName
    XMPPRoomHybridStorage *xmppRoomStorage1 = [XMPPRoomHybridStorage sharedInstance];
XMPPJID *chatRoomJID = [XMPPJID jidWithString:RoomName];
xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:xmppRoomStorage1 jid:chatRoomJID];
[xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];
[xmppRoom activate:xmppStream];
NSXMLElement *history = [NSXMLElement elementWithName:@"history"];
[history addAttributeWithName:@"maxstanzas" stringValue:@"1"];
[xmppRoom joinRoomUsingNickname:self.xmppStream.myJID.user history:nil];

最新更新