3
votes

I am developing a php based website. i want to implement Facebook chat in it.

My question is that how i can use XMPP with BOSH. what is the relation of XMPP and BOSH.

is there any sample source code to get idea how to implement Facebook chat using library such as JAXL or strophe.js

2

2 Answers

3
votes

My question is that how i can use XMPP with BOSH. what is the relation of XMPP and BOSH.

BOSH stands for bidirectional stream over http. It is a specification designed for running XMPP over HTTP, but can be used to run any underlying tcp level protocol over http.

BOSH basically plays within the limitations of the browser i.e. one cannot make more than 2 requests to a particular domain at a time. And within these limits, BOSH is able to emulate a full blown bidirectional pipe between server and the client. Payload can be transmitted using this virtual pipe and user experience wise it is as good as real-time.

Traditionally BOSH is emulated using a technique called long-polling. However, i have successfully been able to run the same using jsonp and websockets (if available).

is there any sample source code to get idea how to implement Facebook chat using library such as JAXL or strophe.js

I bet you will find enough sample examples of a web chat application using strophe.js. All you need is a bosh connection manager like punjab or ebosh (one i wrote), which can connect to any xmpp/jabber c2s endpoint.

As far as JAXL sample example goes, here are a few that you can directly use: https://github.com/abhinavsingh/JAXL/tree/master/app Look specifically at boshchat.php, boshMUCchat.php and preFetchBOSH.php examples which demonstrate the BOSH side support of Jaxl library.

These examples can be used if you are expecting moderate traffic. For a heavy traffic based application i would seriously recommend using a strophe.js based solution.

0
votes

BOSH is a technology for sending messages from a server to a client over HTTP. It was developed for use with XMPP/Jabber as a way to emulate TCP, but could be used by other technologies. Essentially BOSH is just the most used carrier of XMPP messages.

This question might help you more, in relation to actual implementation.