module Network.Xmpp.Session where
import Data.XML.Pickle
import Data.XML.Types(Element)
import Network.Xmpp.Monad
import Network.Xmpp.Pickle
import Network.Xmpp.Types
import Network.Xmpp.Concurrent
sessionXML :: Element
sessionXML = pickleElem
(xpElemBlank "{urn:ietf:params:xml:ns:xmpp-session}session")
()
sessionIQ :: Stanza
sessionIQ = IQRequestS $ IQRequest { iqRequestID = "sess"
, iqRequestFrom = Nothing
, iqRequestTo = Nothing
, iqRequestLangTag = Nothing
, iqRequestType = Set
, iqRequestPayload = sessionXML
}
xmppStartSession :: XmppConMonad ()
xmppStartSession = do
answer <- xmppSendIQ' "session" Nothing Set Nothing sessionXML
case answer of
Left e -> error $ show e
Right _ -> return ()
startSession :: Session -> IO ()
startSession session = do
answer <- sendIQ' Nothing Set Nothing sessionXML session
case answer of
IQResponseResult _ -> return ()
e -> error $ show e