Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
XMPP library for node.js
branch: master

This branch is 6 commits ahead, 645 commits behind node-xmpp:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples
lib
test
LICENSE
README.markdown
package.json

README.markdown

node-xmpp

idiomatic XMPP library for node.js

Installation with npm

npm install node-xmpp

Motivation

You like Strophe.js? You bought a copy of Professional XMPP Programming with JavaScript and jQuery? You even want to use the same XMPP code for the web and node.js? Then you're wrong here: go to xmppjs.

Objectives of node-xmpp:

  • Use node.js conventions, especially EventEmitter, ie. for write buffer control
  • Fast parsing, node-expat was written with this library in mind
  • Client support for both XMPP clients and components
  • Optional server infrastructure with Router
  • After authentication, leave trivial protocol bits to the user (later we could offer helpers for entity capabilities hashing, etc)

Features

  • Client authentication with SASL DIGEST-MD5, PLAIN, ANONYMOUS, X-FACEBOOK-PLATFORM
  • _xmpp-client._tcp SRV record support
  • Simple JID parsing with Stringprep normalization
  • XML builder & serialization
  • xmlns-aware
  • Component connections
  • Run your own server/talk to other servers with xmpp.Router

Dependencies

Design

┌────────────┐ has a ┌────────────┐
│ net.Stream │←──────┤ Connection │
└────────────┘       └─────┬──────┘
                           │
      ┌────────────┬───────┴───┐
      │            │           │
┏━━━━━┷━━━━┓ ┏━━━━━┷━━━━━┓ ┌───┴────┐
┃  Client  ┃ ┃ Component ┃ │ Server │
┗━━━━━━━━━━┛ ┗━━━━━━━━━━━┛ └───┬────┘
                               │
         ┌─────────────────────┤
         │                     │
┌────────┴───────┐ ┌───────────┴────┐
│ OutgoingServer │ │ IncomingServer │
└────────────────┘ └────────────────┘
     has many ↑        ↑ has many
      creates │        │ accepts
             ┏┷━━━━━━━━┷┓
             ┃  Router  ┃
             ┗━━━━━━━━━━┛

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

Desires about the API? Propose them ASAP!

Building XML Elements

strophejs' XML Builder is very convenient for producing XMPP stanzas. node-xmpp 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.

TODO

  • More documentation
  • More tests (Using Vows)
Something went wrong with that request. Please try again.