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)