|
|
|
@ -17,6 +17,7 @@ module Network.Xmpp.Concurrent |
|
|
|
) where |
|
|
|
) where |
|
|
|
|
|
|
|
|
|
|
|
import Control.Applicative ((<$>)) |
|
|
|
import Control.Applicative ((<$>)) |
|
|
|
|
|
|
|
import Control.Arrow (second) |
|
|
|
import Control.Concurrent (threadDelay) |
|
|
|
import Control.Concurrent (threadDelay) |
|
|
|
import Control.Concurrent.STM |
|
|
|
import Control.Concurrent.STM |
|
|
|
import qualified Control.Exception as Ex |
|
|
|
import qualified Control.Exception as Ex |
|
|
|
@ -242,15 +243,15 @@ reconnect :: Integer -- ^ maximum number of retries (Nothing for |
|
|
|
-- unbounded). Numbers of 1 or less will perform exactly |
|
|
|
-- unbounded). Numbers of 1 or less will perform exactly |
|
|
|
-- one retry |
|
|
|
-- one retry |
|
|
|
-> Session -- ^ session to reconnect |
|
|
|
-> Session -- ^ session to reconnect |
|
|
|
-> IO [XmppFailure] -- ^ The failure modes of the retries |
|
|
|
-> IO (Bool, [XmppFailure]) -- ^ The failure modes of the retries |
|
|
|
reconnect maxTries sess = go maxTries |
|
|
|
reconnect maxTries sess = go maxTries |
|
|
|
where |
|
|
|
where |
|
|
|
go t = do |
|
|
|
go t = do |
|
|
|
res <- doRetry sess |
|
|
|
res <- doRetry sess |
|
|
|
case res of |
|
|
|
case res of |
|
|
|
Nothing -> return [] |
|
|
|
Nothing -> return (True, []) |
|
|
|
Just e -> if (t > 1) then (e:) <$> go (t - 1) |
|
|
|
Just e -> if (t > 1) then (second (e:)) <$> go (t - 1) |
|
|
|
else return $ [e] |
|
|
|
else return $ (False, [e]) |
|
|
|
|
|
|
|
|
|
|
|
-- | Reconnect with the stored settings with an unlimited number of retries. |
|
|
|
-- | Reconnect with the stored settings with an unlimited number of retries. |
|
|
|
-- |
|
|
|
-- |
|
|
|
|