MUC Light using XMPPFramework

909 views Asked by At

Has anyone been able to implement mongooseim's muc light (xep-xxx) using xmppframework on ios? I have been trying to create a room but no progress so far. I can't receive any response from mongooseim server whenever I try to send a request for creating a muc light.

The code that I have tried is:

let roomTitle = "\(title)@muclight.hostname.co"
    print("Creating room: \(roomTitle)")
    let room = XMPPRoomLight(roomLightStorage: nil, jid: XMPPJID(string: roomTitle), roomname: "testroom", dispatchQueue: DispatchQueue.main)
    let delegate = UIApplication.shared.delegate as! AppDelegate
    room.addDelegate(self, delegateQueue: DispatchQueue.main)
    room.createRoomLight(withMembersJID: [(delegate.xmppStream?.myJID)!])
    room.activate(delegate.xmppStream)

The above code doesn't seem to work and I can't find a demo on how to do this using xmppframework anywhere online. I have enabled mod_muc_light in ejabberd.cfg by uncommenting the line:

{mod_muc_light, [{host, "muclight.@HOST@"}]}
2

There are 2 answers

0
oveys safarnejad On

seems you need to add configuration for your room.

let query = DDXMLElement(name: "query", xmlns: "urn:xmpp:muclight:0#create")
    let configuraton = DDXMLElement(name: "configuration")
    configuraton.addChild(DDXMLElement(name: "roomname", stringValue: roomName))
    let occupants = DDXMLElement(name: "occupants")
    let users = DDXMLElement(name: "user", stringValue: (XMPPJID(string: "ijpxs3blss@localhost")?.bare)!)
    users.addAttribute(withName: "affiliation", stringValue: "member")
    occupants.addChild(users)
    query.addChild(configuraton)
    query.addChild(occupants)

and at the end call

room.setconfiguration(query)
0
codelover On

Refer this documentation to follow step by step configuration for making the MUC Light Room and chatting:

This is for Mongoose IM but most of the items are same as ejabberd configuration. Just read out the terms to get an idea.

Main Source: https://github.com/esl/MongooseIM

MUCLight: https://github.com/esl/MongooseIM/blob/master/doc/open-extensions/muc_light.md