Modern XMPP in the browser, with a JSON API.
Stanza.io is a library for using modern XMPP in the browser, and it does that by exposing everything as JSON. Unless you insist, you have no need to ever see or touch any XML when using stanza.io.
$ npm install stanza.io
$ grunt
The bundled and minified files will be in the generated build
directory.
- Find or install a server which supports XMPP over WebSocket (Prosody recommended).
- Run
grunt
to buildbuild/stanzaio.bundle.js
- Open
demo.html
in your browser - Enter your connection info, click connect.
- Use the JS console to play with the XMPP client (
var client
).
If you want to see stanza.io in action in a full-featured client, take a look at Otalk.im (and its source).
var XMPP = require('stanza.io'); // if using browserify
var client = XMPP.createClient({
jid: 'echobot@example.com',
password: 'hunter2'
});
client.on('session:started', function () {
client.getRoster();
client.sendPresence();
});
client.on('chat', function (msg) {
client.sendMessage({
to: msg.from,
body: 'You sent: ' + msg.body
});
});
client.connect();
MIT
If you like this, follow @lancestout on twitter.