From 7b9258b676c5dae7297a43661b8885fd0640db26 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Mon, 20 Jan 2014 16:26:26 -0800 Subject: [PATCH] Update README with example --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index 5e40fe80..bd403d14 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,31 @@ The bundled and minified files will be in the generated `build` directory. If you want to see stanza.io in action in a full-featured client, take a look at [Otalk.im](http://otalk.im) (and its [source](https://github.com/andyet/otalk)). +## Echo Client Demo + +```javascript +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(); +``` + ## License MIT