idiomatic XMPP library for node.js
Now usable in browsers too thanks to Browserify.
- Events harmonization
- Common pause/resume/... for any Client/Component/Server session
- Smoothen reconnect
- Websockets server (at least for testing the client)
- Lookup BOSH URLs in DNS TXT records
- Move connecting to connection, use WS/BOSH as TCP fallback
- Use split-out srv library
- Ensure tls end/close/drain events
- Properly disconnect on stream errors, not on connection errors
- Tests for S2S connections
- Tests for Component connections (w/ Component server?)
- Find a browser-based demo app that can be switched from Strophe.js
With package manager npm:
npm install node-xmpp
Please see the various examples.
- Use node.js conventions, especially
EventEmitter, ie. for write buffer control - Fast parsing,
node-expatwas written for this library - Client support for both XMPP clients and components
- Optional server infrastructure with
Router - After authentication, leave trivial protocol bits to the user, that is XML handling according to any XEP
- Client authentication with SASL DIGEST-MD5, PLAIN, ANONYMOUS, X-FACEBOOK-PLATFORM
_xmpp-client._tcpSRV record support- Simple JID parsing with Stringprep normalization
- Optional now, you won't need ICU for just node-xmpp
- Please be aware if you identify users by JIDs
npm install node-stringprep
- Uses ltx
- Much easier to handle than a standard DOM
- xmlns-aware
- Easy XML builder like Strophe.js (see down)
- Non-buffering serialization
- Was split out of node-xmpp for modularization and resuability
- Component connections
- Run your own server/talk to other servers with
xmpp.Router - Even runs in the Browser.
- node-expat (requires libexpat!)
- ltx
Optional
- node-stringprep: for icu-based string normalization.
- node-xmpp-bosh: BOSH & websocket server (connection manager)
- node-xmpp-via-bosh: BOSH client connections from node.js
- node-simple-xmpp: Simpler high-level client layer
- xmpp-server: Reusable XMPP server on top of node-xmpp
- node-xmpp-joap: Jabber Object Access Protocol (XEP-0075) library for node-xmpp
- node-xmpp-serviceadmin: Service Administration (XEP-0133) library for node-xmpp
- Junction: An extensible XMPP middleware layer
- xmpp-ftw: XMPP For The Web ::: Powerful XMPP, simple JSON
Inheritance tree and associations:
ββββββββββββββ1 1ββββββββββββββ
β net.Stream βββββββββ€ Connection β
ββββββββββββββ ββββββββββββββ
β
ββββββββββββββ¬ββββββββ΄ββββ¬βββββββββββββ
β β β β
βββββββ·βββββ βββββββ·ββββββ βββββ΄βββββ βββββββ΄ββββββ
β Client β β Component β β Server β β C2SStream β
ββββββββββββ βββββββββββββ ββββββββββ βββββββββββββ
β β0..*
βββββββββββββββββββββββ€ βaccepts
β β β1
ββββββββββ΄ββββββββ βββββββββββββ΄βββββ βββββββ·ββββββ
β OutgoingServer β β IncomingServer β β C2SServer β
βββββββββββββββ¬βββ βββββ¬βββββββββββββ βββββββ―ββββββ
0..* β β 0..* β
creates β β accepts β
ββ·βββββββββ·β β
β Router βββββββββββββββββββββ
ββββββββββββ 1
This foundation is complemented by two basic data structures:
- JID: a Jabber-Id, represented as a triple of
user,domain,resource - Element: any XML Element
Strophe.js' XML Builder is very convenient for producing XMPP
stanzas. ltx includes it in a much more primitive way: the
c(), cnode() and t() methods can be called on any Element
object, returning the new child element.
This can be confusing: in the end, you will hold the last-added child
until you use up(), a getter for the parent. Connection.send()
first invokes tree() to retrieve the uppermost parent, the XMPP
stanza, before sending it out the wire.
node-xmpp now comes with a prebuilt browser bundle:
<script src="/node_modules/node-xmpp/node-xmpp-browser.js"></script>
<script type="text/javascript">
var client = new XMPP.Client(opts);
</script>