简体   繁体   中英

iOS XMPP group chat implementation

I am trying to create chat room using robbiehanson XMPPframework.

Since I didn't get any sample code or documentation, I made a try by myself to initiate a chat room as follows:

    XMPPRoomMemoryStorage *rosterstorage = [[XMPPRoomMemoryStorage alloc] init];
    XMPPRoom *xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:rosterstorage jid:[XMPPJID jidWithString:@"test@mycompany.com/room"] dispatchQueue:dispatch_get_main_queue()];    
    [xmppRoom configureRoomUsingOptions:nil];
    [xmppRoom activate:[UIAppDelegate xmppStream]];
    [xmppRoom addDelegate:UIAppDelegate
            delegateQueue:dispatch_get_main_queue()];
   [xmppRoom inviteUser:[XMPPJID jidWithString:jabberID] withMessage:@"Hi join room"];

But I am getting the response in the console as :

 RECV: <message xmlns="jabber:client" from="test@mycompany.com" to="user1@mycompany.com/42512304551337785705750233" type="error"><x xmlns="http://jabber.org/protocol/muc#user"><invite to="user2@mycompany.com"><reason>Hi join room</reason></invite></x><error code="503" type="cancel"><service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></message>

Anybody have any idea to initiate MUC??Is there any sample code for this??Any help will be appreciated..Thanks in advance..

Finally I figured it out. It may help someone. While creating or joining the room, the format should be yourRoomName@conference.YourDomainName.com . 'conference' is the keyword here.

Each room is identified as a "room JID" (eg, ), where "room" is the name of the MUC room and "service" is the hostname at which the multi-user chat service is running. Reference XEP-0045

The keyword " conference " is mandatory to use in order to start group chat using XMPP Client.

As far as I know, MUC is not possible with the facebook XMPP server, because it's a stripped down one. They don't say it explicitly, but I found some hints in the pidgin wiki (it's german): http://wiki.pidgin-im.de/index.php/Facebook . I've been struggling with this topic as well...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM