XMPPFramework-如何创建一个多用户聊天室? [英] XMPPFramework - How to Create a MultiUserChat Rooms?
本文介绍了XMPPFramework-如何创建一个多用户聊天室?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用XMPPFramework在iPhone中实现GroupChat.我尝试了休假代码但未创建空间.如何知道是否创建了空间.如何不调用XMPPRoomDelegate.当Stream断开连接时,调用handleDidLeaveRoom方法.可以吗帮助我.感谢前进
How can I Achieve GroupChat in iPhone using XMPPFramework.I tried fallowing code but room is not created.How can I know whether room is created or not.XMPPRoomDelegate are not called.When Stream disconnected, handleDidLeaveRoom method called.Can any one help me.thanks inadvance
#define XMPP_HOSTNAME_2 @"chat.someservername.com"
#define XMPP_JID @"venkat@chat.someservername.com"
#define XMPP_PASSWORD @"venkat"
#define ROOM_JID @"venkat_muc@conference.chat.someservername.com/iMac"
- (void)mucSetupStream
{
xmppStream = [[XMPPStream alloc] init];
xmppStream.hostName = XMPP_HOSTNAME_2;
xmppStream.myJID = [XMPPJID jidWithString:XMPP_JID];
[xmppStream addDelegate:self delegateQueue:dispatch_get_main_queue()];
// Configure xmppRoom
XMPPJID *roomJID = [XMPPJID jidWithString:ROOM_JID];
xmppRoomStorage=[XMPPRoomCoreDataStorage sharedInstance];
xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:self jid:roomJID dispatchQueue:dispatch_get_current_queue()];
[xmppRoom activate:xmppStream];
[xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];
// Start connection process
NSError *err = nil;
if (![xmppStream connect:&err])
{
DDLogError(@"YapTesting: Cannot connect: %@", err);
}
[self performSelector:@selector(ConfigureNewRoom) withObject:nil afterDelay:5];
}
- (void)ConfigureNewRoom
{
NSLog(@"The Room is Configure After 5 Secs");
[xmppRoom fetchConfigurationForm];
[xmppRoom configureRoomUsingOptions:nil];
}
推荐答案
[self ConfigureNewRoom];
XMPPRoomMemoryStorage *roomMemoryStorage = [[XMPPRoomMemoryStorage alloc] init];
XMPPRoom *xmppRoom1 = [[XMPPRoom alloc] initWithRoomStorage:roomMemoryStorage jid:[XMPPJID jidWithString:@"Fun@conference.server.com"] dispatchQueue:dispatch_get_main_queue()];
[xmppRoom1 activate:[self xmppStream]];
[xmppRoom1 joinRoomUsingNickname:@"Fun" history:nil];
[xmppRoom1 addDelegate:self delegateQueue:dispatch_get_main_queue()];
[xmppRoom1 fetchConfigurationForm];
[xmppRoom1 configureRoomUsingOptions:nil];
这篇关于XMPPFramework-如何创建一个多用户聊天室?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文