O'Reilly logo

Practical XMPP by David Koelle, Lloyd Watkin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Telling the server we're online

Once the client is connected, we'll need to tell the server that we're online so that it knows to route any stanzas sent to the bare JID (bot@localhost) through to our script. To do this, we'll need to build a stanza using the library that comes as part of node-xmpp-client called Less than XML or ltx.

We can access ltx via the client object we loaded earlier. To send the presence data, we must first be online, so we'll add a function call in that event to send a presence stanza. Our code now becomes:

const Client = require('node-xmpp-client') , ltx = Client.ltx const options = { jid: 'bot@localhost', password: 'tellnoone' } const client = new Client(options) client.on('online', (connectionDetails) => { console.log('We ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required