Jaxl 2.0 bosh support allow web developers to write real time web applications within minutes, without having any pre-requisite knowledge about the XMPP protocol itself. In this blog post, I will walk you through setup and demo of an XMPP based web chat application using Jaxl library.
Get the code
Follow the following steps to download and install this sample web application on your systems:
- Clone the development branch of Jaxl library
[email protected]:~/git# git clone [email protected]:abhinavsingh/JAXL.git [email protected]ubuntu:~/git# cd JAXL/ [email protected]:~/git/JAXL#
If you are not familiar with git, simply visit [email protected], click Download Source and extract under
~/git/JAXLdirectory on your system
- Once inside Jaxl source directory, build the latest development package
[email protected]:~/git/JAXL# ./build.sh building...
- Install Jaxl library (view installation detail and options)
[email protected]:~/git/JAXL# ./build.sh install uninstalling old package... installing...
Setup web chat application
Jaxl library is default installed under
/usr/share/php/jaxl folder. Application code for our web chat application can be found under
Follow these steps to setup web chat application on your system:
- I assume you have
http://localhost/configured on your local web server and it runs out of
/var/wwwfolder. Create following symlinks:
[email protected]:~/git/JAXL# cd /var/www [email protected]:/var/www# ln -s /usr/share/php/jaxl/app/boshchat/boshchat.php index.php [email protected]:/var/www# ln -s /usr/share/php/jaxl/app/boshchat/jaxl.ini jaxl.ini [email protected]:/var/www# ln -s /usr/share/php/jaxl/env/jaxl.js jaxl.js [email protected]:/var/www# ln -s /usr/bin/jaxl jaxl.php
Edit/Remove #!/usr/bin/env php inside
jaxl.phpif it causes any problem on your system.
- Open and edit jaxl.ini
- I assume you have access to XMPP over Bosh enabled jabber server. Ejabberd users can verify this by hitting
http://localhost:5280/http-bindin the browser
- Open and edit index.php
define('BOSHCHAT_ADMIN_JID', '[email protected]');
All messages sent using this web chat application will be routed to
Ready for the demo
To run this example web chat application, visit
http://localhost in your browser window. Enter a username/password already registered on your jabber server and press connect.
BOSHCHAT_ADMIN_JID using a desktop client, so that you can receive messages sent from the browser on your desktop client.
Below is a screenshot when I logged in as “abhinavsingh” from browser and
BOSHCHAT_ADMIN_JID was set to “[email protected]”: