truckhiem / xmpphp

Automatically exported from code.google.com/p/xmpphp
0 stars 0 forks source link

How Add/Delete group or room conference ? #119

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago

How Add/Delete group or room conference ?

Original issue reported on code.google.com by troe...@gmail.com on 20 Dec 2011 at 6:48

GoogleCodeExporter commented 8 years ago
Here's some code for my specific task:
public function createRoom($service, array $members)
    {
        // send presence packet to room
        $presence = $this->__buildBody();
        $packet = $presence->addChild('presence');
        $packet->addAttribute('from', $this->basejid);

        $nickname = $this->user;//reset(explode('@', $this->basejid));
        $roomName = $this->generateRoomName();
        $fullRoomName = "$roomName@$service/$nickname";
        $packet->addAttribute('to', $fullRoomName);

        $x = $packet->addChild('x');
        $x->addAttribute('xmlns', self::MUC_NAMESPACE);

        $this->__sendBody($presence);

        // save room configuration
        $iq = $this->__buildBody();
        $packet = $iq->addChild('iq');
        $packet->addAttribute('from', $this->fulljid);
        $packet->addAttribute('to', $fullRoomName);
        $packet->addAttribute('type', 'set');

        $query = $packet->addChild('query');
        $query->addAttribute('xmlns', 'http://jabber.org/protocol/muc#owner');

        $x = $query->addChild('x');
        $x->addAttribute('xmlns', 'jabber:x:data');
        $x->addAttribute('type', 'submit');

        $this->__sendBody($iq);

        // modify members
        $packet = $this->__buildBody();
        $iq = $packet->addChild('iq');
        $iq->addAttribute('from', $fullRoomName.'/'.$nickname);
        $iq->addAttribute('to', $fullRoomName);
        $iq->addAttribute('type', 'set');
        $query = $iq->addChild('query');
        $query->addAttribute('xmlns', 'http://jabber.org/protocol/muc#admin');
        foreach($members as $member)
        {
            $item = $query->addChild('item');
            $item->addAttribute('affiliation', 'member');
            $item->addAttribute('jid', $member['jid']);
        }
        $this->__sendBody($packet);

        return $roomName;
    }
this function is added to the subclass of the XMPPHP_BOSH class. You can adopt 
it to your needs.

Original comment by delighta...@gmail.com on 1 Feb 2012 at 1:25

GoogleCodeExporter commented 8 years ago
self::MUC_NAMESPACE not defined in code

Original comment by haresh.v...@slktechlabs.com on 24 Nov 2012 at 9:52