iOS-XMPPFramework-创建群组聊天室-问题 [英] iOS - XMPPFramework - creating a group chatroom - Issue

查看:91
本文介绍了iOS-XMPPFramework-创建群组聊天室-问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发iOS中的聊天应用程序。在XMPP服务器中(在本例中为Ejabberd,我已启用MUC)。我已经注册了一个用户,现在尝试使用注册的用户创建一个聊天室。同样在MUC中,正确设置了主机设置

I am developing a chat app in iOS. In XMPP server (Ejabberd in this case,I have enabled MUC ). I have registered a user and now trying to create a chatroom using an registered user. Also in MUC, the Host setting is defined properly

{host, "conference.@HOST@"}

但是我无法创建聊天室

代码我正在使用以下

XMPPRoomCoreDataStorage *rosterstorage = [[XMPPRoomCoreDataStorage alloc] init]; 
NSString *jid =[[NSUserDefaults standardUserDefaults] valueForKey:@"UserName"]; 
jid=[jid stringByReplacingOccurrencesOfString:@"@localhost" withString:@""]; 
jid=[jid stringByAppendingString:@"@conference.localhost"]; 
NSLog(@"jid is here :%@",jid); 
// timok@conference.localhost 

XMPPRoom *xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:rosterstorage jid:[XMPPJID     jidWithString:jid] dispatchQueue:dispatch_get_main_queue()]; 
[xmppRoom activate:[appdel xmppStream]]; 

[xmppRoom fetchConfigurationForm]; 

[xmppRoom configureRoomUsingOptions:nil]; 
[xmppRoom addDelegate:appdel delegateQueue:dispatch_get_main_queue()]; 
[xmppRoom inviteUser:[XMPPJID jidWithString:@"motik@localhost"] withMessage:@"Hi join room"];

在上面的代码中timok和motik是注册用户。尝试创建房间时,出现以下错误

In the above code timok and motik are registered users. When I attempt to create a room, I am getting the below error

2014-04-29 18:25:27:996 konnectlinks[16112:5e03] SEND: <message to="timok@conference.localhost"><x xmlns="http://jabber.org/protocol/muc#user"><invite to="motik@localhost"><reason>Hi join room</reason></invite></x></message> 
2014-04-29 18:25:28:280 konnectlinks[16112:5a43] RECV: <iq xmlns="jabber:client" from="localhost" id="99D56CEF-3DEA-4D3D-B186-D3B1C28FEE8F" type="error"><error code="503" type="cancel"><service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq> 
2014-04-29 18:25:28:280 konnectlinks[16112:a0b] paduaAppDelegate: xmppStream:didReceiveIQ: 
2014-04-29 18:25:28:564 konnectlinks[16112:5a43] RECV: <iq xmlns="jabber:client" from="localhost" id="D9F3BE9A-F4EB-4361-8F1A-C51FD5880AD8" type="error"><error code="503" type="cancel"><service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq> 
2014-04-29 18:25:28:564 konnectlinks[16112:a0b] paduaAppDelegate: xmppStream:didReceiveIQ: 
2014-04-29 18:25:28.564 konnectlinks[16112:a0b] didNotConfigure

关于如何解决此问题的任何想法都会很有帮助。

Any idea on how to resolve this issue will be very helpful.

推荐答案

创建MUC会议室

- (void)createChatRoom:(NSString *) newRoomName
{
    NSString * xmppRoomJID = [NSString stringWithFormat:@"%@@%@", newRoomName, CONFERENCE_ROOM_SERVER_NAME];
    XMPPJID *roomJID = [XMPPJID jidWithString:xmppRoomJID];

    XMPPRoomMemoryStorage *roomMemoryStorage = [[XMPPRoomMemoryStorage alloc] init];

    xmppRoom = [[XMPPRoom alloc]
                initWithRoomStorage:roomMemoryStorage
                jid:roomJID
                dispatchQueue:dispatch_get_main_queue()];

    [xmppRoom activate:[self xmppStream]];
    [xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];
    [xmppRoom joinRoomUsingNickname:[Your Nickname or Number Here] history:nil];
    [xmppRoom fetchConfigurationForm];

}

这篇关于iOS-XMPPFramework-创建群组聊天室-问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆