public
Description: Erlang XMPP Client
Homepage:
Clone URL: git://github.com/engineyard/natter.git
dambalah (author)
Wed May 27 11:04:36 -0700 2009
stesla (committer)
Wed May 27 14:47:34 -0700 2009
natter /
name age message
file .gitignore Wed May 27 14:47:31 -0700 2009 Added a README file Signed-off-by: Samuel Tesl... [dambalah]
file LICENSE Fri Dec 19 09:24:21 -0800 2008 * Adding LGPL license info to all source and ad... [ksmith]
file Makefile.am Mon Jan 12 14:21:23 -0800 2009 Fixed so that just running make will work for i... [Samuel Tesla]
file README.markdown Wed May 27 14:47:34 -0700 2009 fixes to README file Signed-off-by: Samuel Tes... [dambalah]
file configure.ac Mon Feb 23 11:56:10 -0800 2009 Bump version number. [Samuel Tesla]
directory ebin/ Wed Jan 28 12:50:28 -0800 2009 Fix it so that ebin directory exists when check... [Samuel Tesla]
directory examples/ Mon Dec 29 11:12:35 -0800 2008 * Got SRV record resolution working for natter [ksmith]
directory src/ Wed Mar 11 07:27:11 -0700 2009 * Fixed mis-spelling of io:format [ksmith]
directory tests/ Thu Jan 29 14:04:02 -0800 2009 * Added unit tests for new blocking auth behavior [ksmith]
README.markdown

Natter

Natter is an XMPP erlang library. It currently only supports IQ stanzas and has no support for messages, roster, and just enough presence support to be able to connect.

Building Natter

If you've built erlang from source, then do the following:

autoreconf --install
./configure
make
sudo make install

This will install natter at: /usr/local/lib/erlang/lib/

If you are using Ubuntu and installed erlang via apt-get:

autoreconf --install
./configure --prefix=/usr/
make
sudo make install

This will install natter at: /usr/lib/erlang/lib/

Getting Started

Connecting

Config = [{host, "localhost"}, {user, "foo"}, {password, "bar"}, {resource, "foobar"}].
{ok, Cn} = natter_connection:start_link(Config).

Receiving XMPP Messages

An exchange routes packets to interested processes. A process can tell natter that he is interested in hearing all messages that come in (default_exchange) or that he is interested in hearing messages that go to a particular JID.

Default Exchange

Config = [{host, "localhost"}, {user, "foo"}, {password, "bar"}, {resource, "foobar"}].
{ok, Cn} = natter_connection:start_link(Config).
natter_connection:register_default_exchange(self(), Cn).

Specific Exchange

Config = [{host, "localhost"}, {user, "foo"}, {password, "bar"}, {resource, "foobar"}].
{ok, Cn} = natter_connection:start_link(Config).
natter_connection:register_exchange(Cn, "iq", "bar@localhost", self()).

Internals

3 main modules:

  • natter_connection: public API. Runs as a supervisor.

  • natter_packetizer: responsible for dealing with all network traffic. Reads in incoming XML and finds out when you have a complete packet. It then sends the packet to the dispatcher.

  • natter_dispatcher: figures out where packets should go.

XML Parsing is done using an erlang wrapper around libexpat. Inspired by Jabberlang. Faster than xmerl.

XML is parsed into a tuple:

{xmlelement, “iq”, Attrs, Subels}

TODO

  • Move away from plain-text authentication

  • Support for presence

  • Support for message stanzas

  • Support for rosters

Resources/Links

Kevin Smith presents Natter at the Erlang Factory