From fad5e3738404c1b8cb0d6c18cf2460812f81591b Mon Sep 17 00:00:00 2001
From: Philipp Balzarek
Date: Sun, 24 Mar 2013 17:46:00 +0100
Subject: [PATCH] add dropIQChan
---
source/Network/Xmpp.hs | 1 +
source/Network/Xmpp/Concurrent/IQ.hs | 15 +++++++++++++++
2 files changed, 16 insertions(+)
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