Browse Source

make bind save the received JID

master
Philipp Balzarek 14 years ago
parent
commit
697b1398be
  1. 4
      source/Network/Xmpp.hs
  2. 3
      source/Network/Xmpp/Bind.hs

4
source/Network/Xmpp.hs

@ -180,6 +180,6 @@ auth :: Text.Text -- ^ The username @@ -180,6 +180,6 @@ auth :: Text.Text -- ^ The username
-> XmppConMonad (Either AuthError Jid)
auth username passwd resource = runErrorT $ do
ErrorT $ xmppSasl [scramSha1 username Nothing passwd]
res <- lift $ xmppBind resource
jid <- lift $ xmppBind resource
lift $ xmppStartSession
return res
return jid

3
source/Network/Xmpp/Bind.hs

@ -13,6 +13,8 @@ import Network.Xmpp.Types @@ -13,6 +13,8 @@ import Network.Xmpp.Types
import Network.Xmpp.Pickle
import Network.Xmpp.Monad
import Control.Monad.State(modify)
-- Produces a `bind' element, optionally wrapping a resource.
bindBody :: Maybe Text -> Element
bindBody = pickleElem $
@ -29,6 +31,7 @@ xmppBind rsrc = do @@ -29,6 +31,7 @@ xmppBind rsrc = do
answer <- xmppSendIQ' "bind" Nothing Set Nothing (bindBody rsrc)
let Right IQResult{iqResultPayload = Just b} = answer -- TODO: Error handling
let Right jid = unpickleElem jidP b
modify (\s -> s{sJid = Just jid})
return jid
where
-- Extracts the character data in the `jid' element.

Loading…
Cancel
Save