Modern XMPP in the browser, with a JSON API.
Stanza 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.
$ npm install stanza
- Find or install a server which supports XMPP over WebSocket (Prosody recommended).
- Clone this repo with
git clone https://github.com/legastero/stanza.io.git - Run
npm installin the newstanza.iodirectory. - Run
npm run buildto createdist/stanzaio.browser.js. - Open
demo.htmlin your browser. - Enter your connection info, click connect.
- Use the JS console to play with the XMPP client (
var client).
var XMPP = require('stanza');
var client = XMPP.createClient({
jid: 'echobot@example.com',
password: 'hunter2',
// If you have a .well-known/host-meta.json file for your
// domain, the connection transport config can be skipped.
transport: 'websocket',
wsURL: 'wss://example.com:5281/xmpp-websocket'
// (or `boshURL` if using 'bosh' as the transport)
});
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();MUC Room: discuss@stanzajs.org / Logs
If you like this, follow @lancestout on twitter.