Browse Source

some comments

master
Jon Kristensen 14 years ago
parent
commit
0cfad3e2ea
  1. 20
      src/Network/XMPP/Bind.hs

20
src/Network/XMPP/Bind.hs

@ -1,5 +1,7 @@ @@ -1,5 +1,7 @@
{-# LANGUAGE OverloadedStrings #-}
-- TODO: Allow the client to retry the bind with another resource
module Network.XMPP.Bind where
import Data.Text as Text
@ -11,24 +13,36 @@ import Network.XMPP.Types @@ -11,24 +13,36 @@ import Network.XMPP.Types
import Network.XMPP.Pickle
import Network.XMPP.Concurrent
-- A `bind' element.
bindP :: PU [Node] b -> PU [Node] b
bindP c = xpElemNodes "{urn:ietf:params:xml:ns:xmpp-bind}bind" c
-- If the (optional resource) parameter is a `Just' value, a
-- `resource' child element will be added to the `bind' element.
bindBody :: Maybe Text -> Element
bindBody rsrc = (pickleElem
(bindP . xpOption $ xpElemNodes "resource" (xpContent xpId))
rsrc
)
-- Extracts the character data in the `jid' element.
jidP :: PU [Node] JID
jidP = bindP $ xpElemNodes "jid" (xpContent xpPrim)
-- Sends a (synchronous) IQ set request for a (`Just') given or
-- server-generated resource and extract the JID from the non-error
-- response.
xmppThreadedBind :: Maybe Text -> XMPPThread Text
xmppThreadedBind rsrc = do
answer <- sendIQ' Nothing Set Nothing (bindBody rsrc)
let (Right IQResult{iqResultPayload = Just b}) = answer -- TODO: Error handling
let (JID _n _d (Just r)) = unpickleElem jidP b
return r

Loading…
Cancel
Save