From 9e776a39a6ada41385bd8dbe5da212fbfbc5dca1 Mon Sep 17 00:00:00 2001 From: Philipp Balzarek Date: Fri, 4 Jul 2014 20:00:31 +0200 Subject: [PATCH] export streamState --- source/Network/Xmpp.hs | 1 + source/Network/Xmpp/Concurrent/Basic.hs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/source/Network/Xmpp.hs b/source/Network/Xmpp.hs index 5da8a18..0b489f2 100644 --- a/source/Network/Xmpp.hs +++ b/source/Network/Xmpp.hs @@ -58,6 +58,7 @@ module Network.Xmpp , closeConnection , endSession , waitForStream + , streamState -- ** Authentication handlers -- | The use of 'scramSha1' is /recommended/, but 'digestMd5' might be -- useful for interaction with older implementations. diff --git a/source/Network/Xmpp/Concurrent/Basic.hs b/source/Network/Xmpp/Concurrent/Basic.hs index 4f25fbe..a8b731b 100644 --- a/source/Network/Xmpp/Concurrent/Basic.hs +++ b/source/Network/Xmpp/Concurrent/Basic.hs @@ -1,6 +1,7 @@ {-# OPTIONS_HADDOCK hide #-} module Network.Xmpp.Concurrent.Basic where +import Control.Applicative import Control.Concurrent.STM import qualified Control.Exception as Ex import Control.Monad.State.Strict @@ -70,3 +71,8 @@ waitForStream Session{streamRef = sr} = atomically $ do Plain -> return () Secured -> return () _ -> retry + +streamState :: Session -> STM ConnectionState +streamState Session{streamRef = sr} = do + s <- readTMVar sr + streamConnectionState <$> (readTMVar $ unStream s)