XMPP Service Discovery framework for Node, built on Junction.
Junction/Disco is a minimalist framework layered on top of Junction, providing robust tooling to applications that need complete support for service discovery, including information and item queries, as well as JID+node addressing.
The Junction/Disco architecture is modeled upon the proven pairing of Connect + Express, making development of XMPP applications as simple as that of web applications.
$ npm install junction-disco
To create a new application, simply invoke disco()
.
var app = disco();
Junction/Disco uses the fragment identifier of the http://jabber.org/protocol/disco
XML namespace to provide a routing API. For example, a query may want to discover
items associated with a band:
app.items('bands/:id', function(req, res, next) {
Band.findById(req.params.id, function(err, band) {
if (err) { return next(err); }
var jid = req.to.toString();
var items = res.c('query', { xmlns: 'http://jabber.org/protocol/disco#items' });
band.albums.forEach(function(album) {
var node = 'bands/' + band.id + '/' + album.id;
items.c('item', { jid: jid, node: node, name: album.name });
});
res.send();
});
});
Service discovery is a protocol that runs over XMPP, along side other extension
protocols. Because of this, the service discovery app
is typically mounted as
a sub-app of larger XMPP application.
var xmpp = junction()
.use(junction.logger())
.use(app); // use disco app in larger XMPP app
xmpp.connect({ jid: '[email protected]', password: 's3cr3t' });
$ npm install --dev
$ make test
(The MIT License)
Copyright (c) 2011 Jared Hanson
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.