From 5831a7b42f3138c931d950e45f6c4778ef072dfb Mon Sep 17 00:00:00 2001 From: Philipp Balzarek Date: Tue, 2 Jul 2013 13:02:02 +0200 Subject: [PATCH] add waitForStream --- source/Network/Xmpp/Concurrent/Basic.hs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/Network/Xmpp/Concurrent/Basic.hs b/source/Network/Xmpp/Concurrent/Basic.hs index a590f64..8c48559 100644 --- a/source/Network/Xmpp/Concurrent/Basic.hs +++ b/source/Network/Xmpp/Concurrent/Basic.hs @@ -51,3 +51,12 @@ getFeatures :: Session -> IO StreamFeatures getFeatures Session{streamRef = st} = do s <- atomically $ readTMVar st withStream' (gets streamFeatures) s + +waitForStream :: Session -> IO () +waitForStream Session{streamRef = sr} = atomically $ do + s <- readTMVar sr + ss <- readTMVar $ unStream s + case streamConnectionState ss of + Plain -> return () + Secured -> return () + _ -> retry