Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Erlang XMPP Client
Erlang C
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
ebin
examples
src
tests
.gitignore
LICENSE
Makefile.am
README.markdown
configure.ac

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

Something went wrong with that request. Please try again.