Browse Source

minor formatting and documentation additions

master
Jon Kristensen 14 years ago
parent
commit
c029d6e1d4
  1. 15
      src/Network/XMPP/Concurrent/IQ.hs

15
src/Network/XMPP/Concurrent/IQ.hs

@ -12,13 +12,14 @@ import Network.XMPP.Concurrent.Monad
import Network.XMPP.Types import Network.XMPP.Types
-- | Sends an IQ, returns a 'TMVar' that will be filled with the first inbound -- | Sends an IQ, returns a 'TMVar' that will be filled with the first inbound
-- IQ with a matching ID that has type @result@ or @error@ -- IQ with a matching ID that has type @result@ or @error@.
sendIQ :: Maybe JID -- ^ Recipient (to) sendIQ :: Maybe JID -- ^ Recipient (to)
-> IQRequestType -- ^ IQ type (Get or Set) -> IQRequestType -- ^ IQ type (@Get@ or @Set@)
-> Maybe LangTag -- ^ Language tag of the payload (Nothing for default) -> Maybe LangTag -- ^ Language tag of the payload (@Nothing@ for
-> Element -- ^ The iq body (there has to be exactly one) -- default)
-> Element -- ^ The IQ body (there has to be exactly one)
-> XMPP (TMVar IQResponse) -> XMPP (TMVar IQResponse)
sendIQ to tp lang body = do -- TODO: add timeout sendIQ to tp lang body = do -- TODO: Add timeout
newId <- liftIO =<< asks idGenerator newId <- liftIO =<< asks idGenerator
handlers <- asks iqHandlers handlers <- asks iqHandlers
ref <- liftIO . atomically $ do ref <- liftIO . atomically $ do
@ -30,7 +31,7 @@ sendIQ to tp lang body = do -- TODO: add timeout
sendStanza . IQRequestS $ IQRequest newId Nothing to lang tp body sendStanza . IQRequestS $ IQRequest newId Nothing to lang tp body
return ref return ref
-- | like 'sendIQ', but waits for the answer IQ -- | Like 'sendIQ', but waits for the answer IQ.
sendIQ' :: Maybe JID sendIQ' :: Maybe JID
-> IQRequestType -> IQRequestType
-> Maybe LangTag -> Maybe LangTag
@ -40,6 +41,7 @@ sendIQ' to tp lang body = do
ref <- sendIQ to tp lang body ref <- sendIQ to tp lang body
liftIO . atomically $ takeTMVar ref liftIO . atomically $ takeTMVar ref
-- TODO: What is the TVar Bool? Why are they in a tuple?
answerIQ :: (IQRequest, TVar Bool) answerIQ :: (IQRequest, TVar Bool)
-> Either StanzaError (Maybe Element) -> Either StanzaError (Maybe Element)
-> XMPP Bool -> XMPP Bool
@ -53,7 +55,6 @@ answerIQ ((IQRequest iqid from _to lang _tp bd), sentRef) answer = do
case sent of case sent of
False -> do False -> do
writeTVar sentRef True writeTVar sentRef True
writeTChan out response writeTChan out response
return True return True
True -> return False True -> return False
Loading…
Cancel
Save