Practical XMPP

Practical XMPP

Practical XMPP
About the Authors
About the Reviewers
Free Chapter
An Introduction to XMPP and Installing Our First Server

Hello (hello, hello...)! Is there anybody out there?

Finally, it would be great to know if our bot was alive and kicking, or being lazy and taking a break from its duties and having a rest. To determine this information, we'll need to use presence and presence subscriptions. First, we'll update our code to tell the server that we're available on connection, make a presence subscription request to our bot (which it will automatically accept), and then display the presence of the bot on screen.

Let's add a little piece of HTML to index.html and default the bot to showing as offline (you just can't get the right bots sometimes!):

<p class="bot-status">Offline</p> 

Now that we have this code in place, our first task is to send our own presence availability to the server once we've successfully logged in. We'll need to update the connected method to send our presence out:

var connected = function(details) { 
Unlock full access

Continue reading with a subscription

Packt gives you instant online access to a library of over 7,500 practical eBooks and videos, constantly updated with the latest in tech

Your notes and bookmarks