3

Hi I'm developing a chat application in IOS and completed one to one chat, after searching a lot about groupChat, unable to got how to create a normal group in xmppframework.

What I already tried here is a link

iOS XMPP group chat implementation

Accepting chatroom invitation

How to create MultiUserChatRoom using XMPPFramework in iPhone

XMPPFramework - How to Create a MultiUserChat Rooms?

But didnt get any positive response from these above links,

In coding I tried

XMPPRoomCoreDataStorage *rosterstorage = [[XMPPRoomCoreDataStorage alloc] init];
    XMPPRoom *xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:rosterstorage jid:[XMPPJID jidWithString:@"test@conference.domainName.com/rohit"] dispatchQueue:dispatch_get_main_queue()];
    [xmppRoom configureRoomUsingOptions:nil];
    [xmppRoom activate:[self xmppStream]];
    [xmppRoom addDelegate:self
            delegateQueue:dispatch_get_main_queue()];
    [xmppRoom inviteUser:[XMPPJID jidWithString:@"abc@domainName.com"] withMessage:@"Hi join room"];

Also this

- (void)createOrEnterRoom:(NSString *)roomName
{
    //here we enter a room, or if the room does not yet exist, this method creates it
    //per XMPP documentation: "If the room does not yet exist, the service SHOULD create the room"
    //this method accepts an argument which is what you would baptize the room you wish created
    XMPPPresence *presence = [XMPPPresence presence];
    NSString *room = [roomName stringByAppendingString:@"@conference.domain.com"];
    [presence addAttributeWithName:@"to" stringValue:room];
    NSXMLElement *x = [NSXMLElement elementWithName:@"x" xmlns:@"http://jabber.org/protocol/muc"];
    NSXMLElement *history = [NSXMLElement elementWithName:@"history"];
    [history addAttributeWithName:@"maxstanzas" stringValue:@"50"];
    [x addChild:history];
    [presence addChild:x];
    [[self xmppStream] sendElement:presence];
}

Last one is

-(void)createGroup
{
    @try {
        NSString *username=@"user_3";//[self.userDefault valueForKey:@"userid"];

        NSXMLElement *presenceElement=[NSXMLElement elementWithName:@"presence"];

        [presenceElement addAttributeWithName:@"type" stringValue:@"groupchat"];

        [presenceElement addAttributeWithName:@"from" stringValue:[NSString stringWithFormat:@"%@%@",username,HostName]];

        [presenceElement addAttributeWithName:@"to" stringValue:[NSString stringWithFormat:@"testGroup@conference.%@/%@",HostName,username]];

        NSXMLElement *xElement=[NSXMLElement elementWithName:@"x" xmlns:@"http://jabber.org/protocol/muc"];

        NSXMLElement *historyElement=[NSXMLElement elementWithName:@"history"];

        [xElement addChild:historyElement];

        [presenceElement addChild:xElement];

        [self.xmppStream sendElement:presenceElement];
    }
    @catch (NSException *exception) {
    }


}

Anyone please show me a way to solve out this. Please also let me know if we need to configure something extra in ejjabered configuration.

Community
  • 1
  • 1
Rohit Pathak
  • 359
  • 4
  • 16
  • Hi guys at last I find the solution here http://stackoverflow.com/questions/11791022/trouble-creating-xmpp-muc-room-code-503-service-unavailable – Rohit Pathak Apr 11 '14 at 11:41

4 Answers4

2

Please find go through this i found best and detailed answer here .

Trouble creating xmpp muc room: Code 503 (service unavailable)

Community
  • 1
  • 1
Arpan Dixit
  • 995
  • 1
  • 12
  • 24
1

Infact group chat is not provided by XMPP, its a chat room that you have created with XMPPRoom, or you can say conversation. You cant send offline group messages with this.

I have implement Group chat in my http://www.catchbuddies.com/ project with the help of other custom server.

You can make and configue group chat with the help of some webservces for Groups.

Amit Bhavsar
  • 1,273
  • 12
  • 23
0

You should check your muc settings of ejabberd server configuration. make sure muc host is set correctly.

in my case, I changed host to {host, "pub.@HOST@"}, then I tried to join room "test@conference.@HOST@" always got service unavailable error, it took me a whole night to fix.

also, you can use imessage login to your jabber server with admin user, and create chat room before you run ios client.

Change ejabberd log level to debug may help a lot.

xqterry
  • 632
  • 4
  • 10
0

For group creation change setting for muc_room. Also prefer this url will suggest the way for setting https://serverfault.com/questions/185770/configuring-ejabberd-for-multi-user-chat

Community
  • 1
  • 1
BalKrishan Yadav
  • 467
  • 7
  • 21