pontarius-xmpp: An XMPP client library

[ bsd3, library, network ] [ Propose Tags ]

Pontarius XMPP is a work in progress implementation of RFC 6120 ("XMPP CORE"), RFC 6121 ("XMPP IM"), and RFC 6122 ("XMPP ADDR"). While in alpha, Pontarius XMPP works quite well and fulfills most requirements of the RFCs.


[Skip to Readme]

Modules

[Index] [Quick Jump]

  • Network
    • Network.Xmpp
      • Network.Xmpp.Concurrent
        • Network.Xmpp.Concurrent.Basic
        • Network.Xmpp.Concurrent.IQ
        • Network.Xmpp.Concurrent.Message
        • Network.Xmpp.Concurrent.Monad
        • Network.Xmpp.Concurrent.Presence
        • Network.Xmpp.Concurrent.Threads
        • Network.Xmpp.Concurrent.Types
      • Network.Xmpp.IM
      • Network.Xmpp.Internal
      • Network.Xmpp.Lens
      • Network.Xmpp.Marshal
      • Network.Xmpp.Sasl
        • Network.Xmpp.Sasl.Common
        • Network.Xmpp.Sasl.Mechanisms
          • Network.Xmpp.Sasl.Mechanisms.DigestMd5
          • Network.Xmpp.Sasl.Mechanisms.Plain
          • Network.Xmpp.Sasl.Mechanisms.Scram
        • Network.Xmpp.Sasl.StringPrep
        • Network.Xmpp.Sasl.Types
      • Network.Xmpp.Stanza
      • Network.Xmpp.Stream
      • Network.Xmpp.Tls
      • Network.Xmpp.Types
      • Network.Xmpp.Utilities

Flags

Automatic Flags
NameDescriptionDefault
with-th

Enable Template Haskell support

Enabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.0.2.0, 0.0.3.0, 0.0.4.0, 0.0.5.0, 0.0.6.0, 0.0.7.0, 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.2.0.0, 0.2.0.1, 0.3.0.0, 0.3.0.1, 0.3.0.2, 0.3.0.3, 0.4.0.0, 0.4.0.1, 0.4.0.2, 0.4.1.0, 0.4.2.0, 0.4.2.1, 0.4.2.2, 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, 0.5.6.1, 0.5.6.2, 0.5.6.3, 0.5.6.4, 0.5.6.5, 0.5.6.6, 0.5.6.7, 0.5.6.8, 0.5.7.0
Change log ChangeLog.md
Dependencies attoparsec (>=0.10.0.3), base (>4 && <5), base64-bytestring (>=0.1.0.0), binary (>=0.4.1), bytestring (>=0.9.1.9), conduit (>=1.3 && <1.4), containers (>=0.4.0.0), crypto-api (>=0.9), cryptohash (>=0.6.1), cryptohash-cryptoapi (>=0.1), crypton-x509-system (>=1.4), data-default (>=0.2), dns (>=3.0), exceptions (>=0.6), hslogger (>=1.1.0), iproute (>=1.2.4), lens, lens-family, lifted-base (>=0.1.0.1), mtl (>=2.0.0.0), network (>=2.3.1.0), profunctors (>=4), pureMD5 (>=2.1.2.1), random (>=1.0.0.0), resourcet (>=0.3.0), split (>=0.1.2.3), stm (>=2.4), stringprep (>=1.0.0), template-haskell (>=2.5), text (>=0.11.1.5), tls (>=1.3.9), transformers (>=0.3), unbounded-delays (>=0.1), void (>=0.5.5), xml-conduit (>=1.1.0.7), xml-picklers (>=0.3.3), xml-types (>=0.3.1) [details]
License BSD-3-Clause
Copyright Dmitry Astapov, Pierre Kovalev, Mahdi Abdinejadi, Jon Kristensen, IETF Trust, Philipp Balzarek, Sergey Alirzaev
Author Philipp Balzarek
Maintainer l29ah@cock.li
Category Network
Home page https://github.com/l29ah/pontarius-xmpp/
Bug tracker https://github.com/l29ah/pontarius-xmpp/issues/
Source repo head: git clone https://github.com/l29ah/pontarius-xmpp.git
this: git clone https://github.com/l29ah/pontarius-xmpp.git(tag 0.5.7.0)
Uploaded by SergeyAlirzaev at 2024-06-18T10:52:44Z
Distributions LTSHaskell:0.5.7.0, NixOS:0.5.7.0, Stackage:0.5.7.0
Reverse Dependencies 4 direct, 1 indirect [details]
Downloads 25165 total (49 in the last 30 days)
Rating 2.25 (votes: 2) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for pontarius-xmpp-0.5.7.0

[back to package description]

Pontarius XMPP

Pontarius XMPP is a Haskell XMPP client library that implements the capabilities of RFC 6120 ("XMPP CORE"), RFC 6121 ("XMPP IM"), and RFC 6122 ("XMPP ADDR"). Pontarius XMPP was part of the Pontarius project, an effort to produce free and open source, uncentralized, and privacy-aware software solutions.

While in alpha, Pontarius XMPP works quite well and fulfills most requirements of the RFCs.

Prerequisites

Pontarius XMPP requires GHC 7.0, or later.

You will need the ICU Unicode library and it's header files in order to be able to build Pontarius XMPP. On Debian, you will need to install the libicu-dev package. In Fedora, the package is called libicu-devel.

Note to users of GHC 7.0 and GHC 7.2: You will need cabal-install, version 0.14.0 or higher, or the build will fail with an "unrecognized option: --disable-benchmarks" error. The versions 1.16.0 and higher might not build on your system; if so, install 0.14.0 with "cabal install cabal-install-0.14.0".

Note to users of GHC 7.2.1: Due to a bug, recent versions of the binary package wont build without running "ghc-pkg trust base".

Note to users of GHC 7.0.1: You will want to configure your Cabal environment (including cabal-install) for version 0.9.2.1 of bytestring.

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 Text 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 Session object can be acquired by calling session. This object will be used for interacting with the library.

result <- session
             "example.com"
              (Just (\_ -> ( [scramSha1 "username" Nothing "password"])
                           , Nothing))
              def

The three parameters above are the XMPP server realm, a SASL handler (for authentication), and the session configuration settings (set to the default settings). session 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 Session object.

The return type of session is IO (Either XmppFailure Session). As XmppFailure is an Control.Monad.Error instance, you can utilize the ErrorT 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 def sess

Here, def refers to the default Presence value, which is the same as Presence Nothing Nothing Nothing Nothing Available [].

Now, let's say that we want to receive all message stanzas, and echo the stanzas back to the sender. 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."

You don't need to worry about escaping your Text values - Pontarius XMPP (or rather, xml-picklers) will take care of that for you.

Additional XMPP threads can be created using dupSession and forkIO.

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