pontarius-xmpp: An incomplete implementation of RFC 6120 (XMPP: Core)

[ bsd3, library, network ] [ Propose Tags ]

Pontarius XMPP is a work in progress implementation of RFC 6120 (XMPP: Core).

[Skip to Readme]
Versions [faq],,,,,,,,,,,,,,,,,,,,,, 0.4.3, 0.4.4, 0.4.5, 0.5.0, 0.5.1, 0.5.2, 0.5.3, 0.5.4, 0.5.5, 0.5.6,,,
Dependencies attoparsec (>=, base (>4 && <5), base64-bytestring (>=, binary (>=0.4.1), bytestring (>=, conduit (>=0.5 && <1.0), containers (>=, crypto-api (>=0.9), crypto-random-api (>=0.2), cryptohash (>=0.6.1), data-default (>=0.2), dns (>=0.3.0), hslogger (>=1.1.0), iproute (>=1.2.4), lifted-base (>=, mtl (>=, network (>=2.3), pureMD5 (>=, random (>=, resourcet (>=0.3.0), split (>=, stm (>=, stringprep (>=0.1.3), text (>=, tls (>=1.1.0), tls-extra (>=0.5.0), transformers (>=, void (>=0.5.5), xml-conduit (>=1.0), xml-picklers (>=0.3), xml-types (>=0.3.1) [details]
License LicenseRef-OtherLicense
Copyright Dmitry Astapov, Pierre Kovalev, Mahdi Abdinejadi, Jon Kristensen, IETF Trust, Philipp Balzarek
Author Jon Kristensen, Mahdi Abdinejadi, Philipp Balzarek
Maintainer info@jonkri.com
Category Network
Home page https://github.com/jonkri/pontarius-xmpp/
Bug tracker mailto:info@jonkri.com
Source repo head: git clone git://github.com/jonkri/pontarius-xmpp.git
this: git clone git://github.com/jonkri/pontarius-xmpp.git(tag
Uploaded by JonKristensen at 2013-03-20T13:04:58Z
Distributions NixOS:
Downloads 20885 total (14 in the last 30 days)
Rating 2.25 (votes: 2) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs uploaded by user
Build status unknown [no reports yet]




Maintainer's Corner

For package maintainers and hackage trustees

Readme for pontarius-xmpp-

[back to package description]

Welcome to Pontarius XMPP!

Pontarius XMPP is an active work in progress to build a Haskell XMPP library that implements the client capabilities of RFC 6120.

Getting started

The latest release of Pontarius XMPP, as well as its module API pages, can always be found at the Pontarius XMPP Hackage page.

Note: Pontarius XMPP is still in its Alpha phase. Pontarius XMPP is not yet feature-complete, it may contain bugs, and its API may change between versions.

The first thing to do is to import the modules that we are going to use. We are also using the OverloadedStrings LANGUAGE pragma in order to be able to type <code>Text</code> values like strings.

{-# LANGUAGE OverloadedStrings #-}

import Network.Xmpp

import Control.Monad
import Data.Default
import System.Log.Logger

Pontarius XMPP supports hslogger logging. Start by enabling console logging.

updateGlobalLogger "Pontarius.Xmpp" $ setLevel DEBUG

When this is done, a <code>Session</code> object can be acquired by calling <code>session</code>. This object will be used for interacting with the library.

result <- session
              (Just ([scramSha1 "username" Nothing "password"], Nothing))

The three parameters above are the XMPP server realm, the session configuration settings (set to the default settings), and a SASL handler (for authentication). <code>session</code> will perform the necessary DNS queries to find the address of the realm, connect, establish the XMPP stream, attempt to secure the stream with TLS, authenticate, establish a concurrent interface for interacting with the stream, and return the <code>Session</code> object.

The return type of <code>session</code> is <code>IO (Either XmppFailure Session)</code>. As <code>XmppFailure</code> is an <code>Control.Monad.Error</code> instance, you can utilize the <code>ErrorT</code> monad transformer for error handling. A more simple way of doing it could be doing something like this:

sess <- case result of
            Right s -> return s
            Left e -> error $ "XmppFailure: " ++ (show e)

Next, let us set our status to Online.

sendPresence (Presence Nothing Nothing Nothing Nothing Nothing []) sess

Now, let's say that we want to receive all message stanzas, and echo the stanzas back to the recipient. This can be done like so:

forever $ do
    msg <- getMessage sess
    case answerMessage msg (messagePayload msg) of
        Just answer -> sendMessage answer sess
        Nothing -> putStrLn "Received message with no sender."

Additional XMPP threads can be created using <code>dupSession</code> and <code>forkIO</code>.

For a public domain example of a simple Pontarius XMPP (Cabal) project, refer to the examples/echoclient directory.

More information

Feel free to contact Jon Kristensen if you have any questions or comments.