XEP 0045 – Multi User Chat (MUC) available methods in Jaxl 2.0

Jaxl 2.0.3 (Jabber XMPP Library in PHP) comes with 15 XMPP extensions including XEP-0045 a.k.a. Multi-User Chat (Conference Room). In this blog post, we will go through all the methods available for XMPP applications developed using Jaxl library.

Using MUC methods
You need to include Jaxl implementation of XEP-0045 in your application code to start using the methods listed below. Refer Jaxl Installation, Usage guide and Example apps if you are new to Jaxl. Here is how this can be done at the top of your application code:

// initialize Jaxl instance
$jaxl = new JAXL();

// include MUC XEP
jaxl_require('JAXL0045', $jaxl); // or simply $jaxl->requires('JAXL0045');

Multi-User Chat available methods:
Below is a detailed list of methods from multi-user room extension:

  • $jaxl->JAXL0045(‘joinRoom’, $jid, $roomJid.”/”.$nick, $history=0, $type=’seconds’)
  • $jaxl->JAXL0045(‘exitRoom’, $jid, $roomJid)
  • $jaxl->JAXL0045(‘kickOccupant’, $fromJid, $nick, $roomJid, $reason=FALSE, $callback=FALSE)
  • $jaxl->JAXL0045(‘getRoomConfig’, $jid, $roomJid, $callback=FALSE)
  • $jaxl->JAXL0045(‘setRoomConfig’, $jid, $roomJid, $fields, $callback=FALSE)
  • $jaxl->JAXL0045(‘grantOwnerPrivileges’, $fromJid, $toJid, $roomJid, $reason=FALSE, $callback=FALSE)
  • $jaxl->JAXL0045(‘revokeOwnerPrivileges’, $fromJid, $toJid, $roomJid, $reason=FALSE, $callback=FALSE)
  • $jaxl->JAXL0045(‘grantAdminPrivileges’, $fromJid, $toJid, $roomJid, $reason=FALSE, $callback=FALSE)
  • $jaxl->JAXL0045(‘removeAdminPrivileges’, $fromJid, $toJid, $roomJid, $reason=FALSE, $callback=FALSE)

All parameters are mandatory to be passed while calling the above available methods. To be continued as more method gets added like banUser, destroyRoom, etc.

  • Dark

    Great! Can we hope for article about a simple Multi-User Chat? 🙂 For example, how to add MUC in “Boshchat” application?

  • Hi Dark,

    All you need is to enter the connected jid inside bosh application into a MUC room using above methods. e.g. $jaxl->joinRoom(“[email protected]”, “[email protected]”);

    Good luck 🙂

  • Dark

    Oh, thank you 🙂
    May be it was a trouble with ejabberd server, because if I trying to connect to a room (JAXL0045::joinRoom(…)), nothing happens (server response empty body )

  • probably set loglevel to 5 inside ejabberd.cfg and examine logs. Let me know if library pose any problems for you.

  • Dark

    Unfortunately, I don’t have access to ejabberd configs and logs – but I will send request to server administrator for access to this.
    Thanks for help

  • neo

    I have same problem on OpenFire server.
    Im using boshchat example code by adding to requires ‘JAXL0045’ and ‘JAXL0045::joinRoom($jaxl->jid, ‘[email protected]’);’ line to ‘postAuth’ callback, but nothing happends.

    Server logs shows only one line of warning:
    2010.08.29 16:33:16 Closing session due to incorrect hostname in stream header. Host: localhost. Connection: [email protected] socket: Socket[addr=/,port=59107,localport=5269] session: null

  • Hi Neo,

    Can you also paste the jaxl.log for the session (default location /var/log/jaxl.log). That should help in debugging this problem.

  • neo

    Thank you for reply

    There is no any information about conference in the log file. I think that the problem in my script.
    Single user mode works fine.
    Can you test my script file please.

  • Hi Neo,

    Yup i shall test your script file but before that I need a little more info.

    Can you set JAXL_LOG_LEVEL to 5 inside jaxl.ini and update boshchat.zip accordingly. This will help me understand if browser session/cookie is maintained in proper order.

  • neo

    already updated

  • Hi Neo,

    There are a few mistakes in the script and hence doesn’t work for you. For instance while joining the room, do something like this: JAXL0045::joinRoom($jaxl->jid, $roomJid.”/”.$nick);

    The above documentation didn’t reflect this, and I have updated the same. You can try your script again by updating joinRoom method call.

    Give me some time and I shall checkin a working version of boshchat application with MUC integration for your reference.

  • neo

    Thanks a lot

  • Hi Neo,

    Kindly checkout the latest from master branch at github http://github.com/abhinavsingh/JAXL – It has a sample Bosh MUC Chat application, kindly try that.

    Note: You need to checkout whole master branch, since it contains code specific to Jaxl v 2.1.x release, which will change how XEP methods are called inside application code. E.g. JAXL0045::joinRoom($jid, $roomJid.”/”.$nick, $history=0, $type=’seconds’) will now become $jaxl->JAXL0045('joinRoom', $jid, $roomJid.”/”.$nick, $history=0, $type=’seconds’). There are a few other minor changes in the way you call jaxl_require() method.

    I shall update various documentation posts once 2.1.x is marked stable and released on google code.

    Let me know how it goes.

  • neo

    Hi Abhinav,

    WOW, it works!
    Thanks a lot for your help.




  • Hi Nikhil,

    I think you are looking for a chat widget on your website…. simply submit your domain at http://im.jaxl.im …. once your domain is approved, you will be able to see a fbskin style chat bar (customizable/pluggable) on your website.

    You can find the same on lower right corner on my blog.

  • Hello,

    Can you please explain shortly how I can do:

    1. How I can get online user list from conference? Seems this functionality currently not implemented in XEP0045. I’ll try to add:
    public static function getRoomOccupants($jaxl, $jid, $roomJid, $callback=false) {
    $payload = ”;
    $payload .= ”;
    $payload .= ”;
    return XMPPSend::iq($jaxl, “get”, $payload, $roomJid, $jid, $callback);
    But something looking as wrong.

    2. How I can load some history on event ‘connect’? Seems like method have a properties:

    $oJaxl->JAXL0045(‘joinRoom’, $oJaxl->jid, BOSHCHAT_ROOM_JID.’/’.$nick, 0, ‘seconds’);

    But nothing happens if I change parameters.

    Thanks in advance for your comments about subject.

    Zip Driver.

  • Upssss…. code in above post was cleared 🙁

  • Lyn

    Hi Abhinav,
    I am trying to implement the boshmuchat example (on a windows machine running apache and ejabberd) without success. Messages posted are not displayed in the chat window.

    Below are excerpts from jaxl.log and ejabbberd.log


    [1:3136:0] 2011-07-17 17:50:20 – [[XMPPSend]] body

    [1:3136:0] 2011-07-17 17:50:20 – [[XMPPGet]]

    [1:3136:0] 2011-07-17 17:50:20 – [[BoshOut]]


    =INFO REPORT==== 2011-07-17 16:50:20 ===
    D(:ejabberd_http_bind:919) : OutPacket: [{xmlstreamelement,
    [email protected]/mary”},
    [email protected]/jaxl.1.1310914214”},

    =INFO REPORT==== 2011-07-17 16:50:20 ===
    D(:ejabberd_http_bind:1057) : — outgoing data —
    — END —
    =INFO REPORT==== 2011-07-17 16:51:50 ===
    I(:ejabberd_http_bind:509) : Session timeout. Closing the HTTP bind session: “452c75543dcf66817f6fe7e6e0b11890dec10d02”

    =INFO REPORT==== 2011-07-17 16:51:50 ===
    D(:ejabberd_http_bind:550) : terminate: Deleting session 452c75543dcf66817f6fe7e6e0b11890dec10d02

    =INFO REPORT==== 2011-07-17 16:51:50 ===
    I(:ejabberd_c2s:1454) : ({socket_state,ejabberd_http_bind,{http_bind,,{{127,0,0,1},2304}},ejabberd_http_bind}) Close session for [email protected]/jaxl.1.1310914214

    I would appreciate any help in determining what I need to do to fix this.

    Thanks very much

  • Announcing Jaxl v3.x – asynchronous, non-blocking I/O, event based PHP client/server library – http://abhinavsingh.com/blog/2012/07/announcing-jaxl-v3-x-asynchronous-non-blocking-io-event-based-php-clientserver-library/