Browse Source

changed listenIQChan to return the current channel, if one

master
Jon Kristensen 14 years ago
parent
commit
d4390c3e62
  1. 16
      source/Network/Xmpp/Concurrent/Monad.hs

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

@ -19,14 +19,14 @@ import Network.Xmpp.Concurrent.Types
import Network.Xmpp.Monad import Network.Xmpp.Monad
-- | Register a new IQ listener. IQ requests matching the type and namespace -- | Retrieves an IQ listener channel. If the namespace/'IQRequestType' is not
-- will be put in the channel. -- already handled, a new 'TChan' is created and returned as a 'Right' value.
-- -- Otherwise, the already existing channel will be returned wrapped in a 'Left'
-- Return the new channel or Nothing if this namespace/'IQRequestType' -- value. Note that the 'Left' channel might need to be duplicated in order not
-- combination was alread handled. -- to interfere with existing consumers.
listenIQChan :: IQRequestType -- ^ Type of IQs to receive (@Get@ or @Set@) listenIQChan :: IQRequestType -- ^ Type of IQs to receive (@Get@ or @Set@)
-> Text -- ^ Namespace of the child element -> Text -- ^ Namespace of the child element
-> Xmpp (Maybe (TChan IQRequestTicket)) -> Xmpp (Either (TChan IQRequestTicket) (TChan IQRequestTicket))
listenIQChan tp ns = do listenIQChan tp ns = do
handlers <- asks iqHandlers handlers <- asks iqHandlers
liftIO . atomically $ do liftIO . atomically $ do
@ -39,8 +39,8 @@ listenIQChan tp ns = do
byNS byNS
writeTVar handlers (byNS', byID) writeTVar handlers (byNS', byID)
return $ case present of return $ case present of
Nothing -> Just iqCh Nothing -> Right iqCh
Just _iqCh' -> Nothing Just iqCh' -> Left iqCh'
-- | Get a duplicate of the stanza channel -- | Get a duplicate of the stanza channel
getStanzaChan :: Xmpp (TChan Stanza) getStanzaChan :: Xmpp (TChan Stanza)

Loading…
Cancel
Save