Converse.js jabber/xmpp web-client configured for single session support using prebind technique for PHP server-side language.
I used xmpp-prebind-php library to implement Single Session Support for converse.js. With the term "Single Session Support" we mean that we can enable users already authenticated in our website, to be also automatically logged in to chat. Prebind technique is used in order to keep the connection peristent accross page load aka page refresh.
Download zip file or clone the repo into your web server public directory and modify config.php, then open index.php
.
In order to see the difference, open index2.php
to another tab, login with your credentials and reload the page.
Prebind refers to a technique whereby your web application sets up an authenticated BOSH session with a BOSH connection manager (which could be your XMPP server). Then later, in the browser, converse.js attaches to that session that was previously set up.
This reduces network traffic and also speeds up loading times for converse.js. Additionally, because prebinding works with tokens, it’s not necessary for the XMPP client to store users’ passwords).
A BOSH server acts as a bridge between HTTP, the protocol of the web, and XMPP, the instant messaging protocol. Converse.js can only communicate via HTTP, but we need to communicate with an XMPP server in order to chat. So the BOSH server acts as a middle man, translating our HTTP requests into XMPP stanzas and vice versa.