2014-04-30 1 views
0

iOS에서 채팅 앱을 개발 중입니다. XMPP 서버 (이 경우 Ejabberd에서는 MUC를 활성화했습니다). 사용자를 등록하고 등록 된 사용자를 사용하여 대화방을 만들려고합니다. 또한 MUC에서, 호스트 설정이 제대로 iOS - XMPPFramework - 그룹 대화방 만들기 - 문제

{host, "[email protected]@"} 

를 정의하지만 채팅방을 만들 수 아니다

내가 사용하고 코드는 위의 코드 timok에서

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); 
// [email protected] 

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:@"[email protected]"] withMessage:@"Hi join room"]; 

이하이며, motik은 등록 된 사용자입니다. 방을 만들려고하면 아래 오류가 발생합니다.

2014-04-29 18:25:27:996 konnectlinks[16112:5e03] SEND: <message to="[email protected]"><x xmlns="http://jabber.org/protocol/muc#user"><invite to="[email protected]"><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 

이 문제를 해결하는 방법에 대한 아이디어는 매우 유용합니다.

+1

http://stackoverflow.com/questions/11791022/trouble-creating-xmpp-muc-room-code- 503-service-unavailable? – Larme

답변

0
-(void) createOrJoinEventGroupChat:(NSString *) groupJID{ 

    XMPPJID *roomJID = [XMPPJID jidWithString:[NSString stringWithFormat:@"%@@conference.%@",groupJID,SERVER_URL]];  

    XMPPRoom *muc = [[XMPPRoom alloc] initWithRoomStorage:xmppRoomStorage jid:roomJID dispatchQueue:dispatch_get_main_queue()]; 

    [muc activate:xmppStream]; 

    [muc addDelegate:self delegateQueue:dispatch_get_main_queue()]; 

    [muc joinRoomUsingNickname:@"User Name" history:nil]; 

} 
0

- (void)createOrJoinRoomWithRoomName:(NSString *)roomName nickName:(NSString *)nickName 
     { 
      if(roomName && nickName) 
      { 
       _xmppRoomStorage = [XMPPRoomHybridStorage sharedInstance]; 
       XMPPJID *roomJid = [XMPPJID jidWithString:[NSString stringWithFormat:@"%@@%@.%@",roomName,@"conference",self.hostName]]; 
       _xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:_xmppRoomStorage jid:roomJid]; 
       [_xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()]; 
       [_xmppRoom activate:_xmppStream]; 
       NSXMLElement *history = [NSXMLElement elementWithName:@"history"]; 
       [history addAttributeWithName:@"maxstanzas" stringValue:MAX_ROOM_HISTORY]; 
       [_xmppRoom joinRoomUsingNickname:nickName history:history]; 
      } 
      else 
      { 
       NSLog(@"room creation arguments missing"); 
      } 
     } 
0

만들려고 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]; 

}