Over a million developers have joined DZone.

PHP Code, Setup and Demo of Jaxl boshchat application

· Web Dev Zone

Start coding today to experience the powerful engine that drives data application’s development, brought to you in partnership with Qlik.

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

    1. root@ubuntu:~/git# git clone git@github.com:abhinavsingh/JAXL.git  
    2. root@ubuntu:~/git# cd JAXL/  
    3. root@ubuntu:~/git/JAXL# 

  • If you are not familiar with git, simply visit JAXL@github, click Download Source and extract under ~/git/JAXL directory on your system
  • Once inside Jaxl source directory, build the latest development package

    1. root@ubuntu:~/git/JAXL# ./build.sh  
    2. building... 

  • Install Jaxl library (view installation detail and options)

    1. root@ubuntu:~/git/JAXL# ./build.sh install  
    2. uninstalling old package...  
    3. 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 /usr/share/php/jaxl/app/boshchat folder.

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/www folder. Create following symlinks:

    1. root@ubuntu:~/git/JAXL# cd /var/www  
    2. root@ubuntu:/var/www# ln -s /usr/share/php/jaxl/app/boshchat/boshchat.php index.php  
    3. root@ubuntu:/var/www# ln -s /usr/share/php/jaxl/app/boshchat/jaxl.ini jaxl.ini  
    4. root@ubuntu:/var/www# ln -s /usr/share/php/jaxl/env/jaxl.js jaxl.js  
    5. root@ubuntu:/var/www# ln -s /usr/bin/jaxl jaxl.php 

  • Open and edit jaxl.ini

    1. define('JAXL_BOSH_COOKIE_DOMAIN', false); 

  • I assume you have access to XMPP over Bosh enabled jabber server. Ejabberd users can verify this by hitting http://localhost:5280/http-bind in the browser
  • Open and edit index.php

    1. define('BOSHCHAT_ADMIN_JID''admin@localhost');  

    All messages sent using this web chat application will be routed to BOSHCHAT_ADMIN_JID

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.

Login as 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 “jaxl@jaxl.im”:

Create data driven applications in Qlik’s free and easy to use coding environment, brought to you in partnership with Qlik.

Topics:

Published at DZone with permission of Abhinav Singh. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}