From b83de8a11bf631835ee146e51bd7d953c6cb8e60 Mon Sep 17 00:00:00 2001 From: Philipp Balzarek Date: Tue, 30 Apr 2013 15:27:20 +0200 Subject: [PATCH] add getJid --- source/Network/Xmpp.hs | 1 + source/Network/Xmpp/Concurrent/Basic.hs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/source/Network/Xmpp.hs b/source/Network/Xmpp.hs index d864b26..bc8281b 100644 --- a/source/Network/Xmpp.hs +++ b/source/Network/Xmpp.hs @@ -46,6 +46,7 @@ module Network.Xmpp , isFull , jidFromText , jidFromTexts + , getJid -- * Stanzas -- | The basic protocol data unit in XMPP is the XML stanza. The stanza is -- essentially a fragment of XML that is sent over a stream. @Stanzas@ come in diff --git a/source/Network/Xmpp/Concurrent/Basic.hs b/source/Network/Xmpp/Concurrent/Basic.hs index 5b16e4e..912cba5 100644 --- a/source/Network/Xmpp/Concurrent/Basic.hs +++ b/source/Network/Xmpp/Concurrent/Basic.hs @@ -3,7 +3,9 @@ module Network.Xmpp.Concurrent.Basic where import Control.Concurrent.STM import Network.Xmpp.Concurrent.Types +import Network.Xmpp.Stream import Network.Xmpp.Types +import Control.Monad.State.Strict -- | Send a stanza to the server. sendStanza :: Stanza -> Session -> IO () @@ -14,3 +16,9 @@ dupSession :: Session -> IO Session dupSession session = do stanzaCh' <- atomically $ dupTChan (stanzaCh session) return $ session {stanzaCh = stanzaCh'} + +-- | Return the JID assigned to us by the server +getJid :: Session -> IO (Maybe Jid) +getJid Session{streamRef = st} = do + s <- atomically $ readTMVar st + withStream' (gets streamJid) s