diff --git a/source/Network/Xmpp.hs b/source/Network/Xmpp.hs index cfb2c14..87d56f1 100644 --- a/source/Network/Xmpp.hs +++ b/source/Network/Xmpp.hs @@ -138,6 +138,7 @@ module Network.Xmpp , sendIQ' , answerIQ , listenIQChan + , dropIQChan -- * Errors , StanzaError(..) , StanzaErrorType(..) diff --git a/source/Network/Xmpp/Concurrent/IQ.hs b/source/Network/Xmpp/Concurrent/IQ.hs index d41e8cf..54f4a17 100644 --- a/source/Network/Xmpp/Concurrent/IQ.hs +++ b/source/Network/Xmpp/Concurrent/IQ.hs @@ -83,6 +83,21 @@ listenIQChan tp ns session = do Nothing -> Right iqCh Just iqCh' -> Left iqCh' +-- | Unregister a previously acquired IQ channel. Please make sure that you +-- where the one who acquired it in the first place as no check for ownership +-- can be made +dropIQChan :: IQRequestType -- ^ Type of IQ ('Get' or 'Set') + -> Text -- ^ Namespace of the child element + -> Session + -> IO () +dropIQChan tp ns session = do + let handlers = (iqHandlers session) + atomically $ do + (byNS, byID) <- readTVar handlers + let byNS' = Map.delete (tp, ns) byNS + writeTVar handlers (byNS', byID) + return () + answerIQ :: IQRequestTicket -> Either StanzaError (Maybe Element) -> Session