Browse Source

export setConnectionClosedHandler

master
Philipp Balzarek 13 years ago
parent
commit
34e80d8fe2
  1. 1
      source/Network/Xmpp.hs
  2. 8
      source/Network/Xmpp/Concurrent/Monad.hs

1
source/Network/Xmpp.hs

@ -27,6 +27,7 @@ module Network.Xmpp @@ -27,6 +27,7 @@ module Network.Xmpp
( -- * Session management
Session
, session
, setConnectionClosedHandler
, StreamConfiguration(..)
, SessionConfiguration(..)
, ConnectionDetails(..)

8
source/Network/Xmpp/Concurrent/Monad.hs

@ -70,9 +70,11 @@ modifyHandlers f session = atomically $ modifyTVar_ (eventHandlers session) f @@ -70,9 +70,11 @@ modifyHandlers f session = atomically $ modifyTVar_ (eventHandlers session) f
x <- readTVar var
writeTVar var (g x)
-- | Sets the handler to be executed when the server connection is closed.
setConnectionClosedHandler_ :: (XmppFailure -> Session -> IO ()) -> Session -> IO ()
setConnectionClosedHandler_ eh session = do
-- | Changes the handler to be executed when the server connection is closed. To
-- avoid race conditions the initial value should be set in the configuration
-- when creating the session
setConnectionClosedHandler :: (XmppFailure -> Session -> IO ()) -> Session -> IO ()
setConnectionClosedHandler eh session = do
modifyHandlers (\s -> s{connectionClosedHandler =
\e -> eh e session}) session

Loading…
Cancel
Save