XMPPFramework - How to Create a MultiUserChat Rooms?

我与影子孤独终老i 提交于 2019-12-30 12:52:08

问题


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];
}

回答1:


 [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];


来源:https://stackoverflow.com/questions/15448784/xmppframework-how-to-create-a-multiuserchat-rooms

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!