HTML and CSS Reference
In-Depth Information
Building a Chat and Instant Messaging
Application over WebSocket
Now that we've walked through some of the important concepts behind using XMPP
over WebSocket, let's take a look at a working example and delve into the more practical
details. Here, we'll use a WebSocket-enabled XMPP server and build a typical chat
application that communicates with the server using XMPP over WebSocket.
Using a WebSocket-Enabled XMPP Server
To build and run the example chat application for this chapter, you will need a
WebSocket-enabled XMPP chat server that is compatible with a client library. As we
mentioned, as of the writing of this topic, there are a few options, including ejabberd-
websockets, an Openfire module, and a proxy called node-xmpp-bosh that understands
the WebSocket Protocol, an open source project built by Dhruv Matan. Because of the
experimental nature of these modules, your mileage may vary. However, these modules
are being rapidly developed, and you'll likely have numerous solid options by the
publication (or your reading) of this topic.
For the purposes of this bleeding-edge example, we've chosen strophe.js for the
client library. To build this example yourself, choose a Websocket-enabled XMPP server
(or update your own XMPP server) and ensure that it is compatible with strophe.js. Alterna-
tively, as previously mentioned, to build (or even follow) the examples in this topic, you can
use the virtual machine (vM) we've created that contains all the code, libraries, and servers
we use in our examples. Refer to Appendix B for instructions on how to download, install,
and start the vM. due to the experimental nature of the technologies used in this chapter
and for learning purposes, we strongly recommend you use the vM we've provided.
Setting Up Test Users
To test your chat application, you need a messaging network with at least two users to
demonstrate interaction. To that end, create a pair of users on the WebSocket-enabled chat
server. Then, you can use these test users to chat back and forth using the application
you'll build in this chapter.
To ensure your server is correctly configured, try connecting two desktop XMPP
clients. For example, you can install any two of the following clients: Pidgin, Psi, Spark,
Adium, or iChat. You can find lots more at . Chances are, you already
have one or two of them installed. In the first chat client, you should see the online status
of the second user. Likewise, you should see the status of the first user in the second
client. Leave one of these users logged in so that you can test your WebSocket chat
application as you develop it.
Search WWH ::

Custom Search