You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.4 KiB
44 lines
1.4 KiB
|
14 years ago
|
{-# LANGUAGE OverloadedStrings #-}
|
||
|
15 years ago
|
|
||
|
14 years ago
|
module Network.Xmpp.Session where
|
||
|
15 years ago
|
|
||
|
14 years ago
|
import Data.XML.Pickle
|
||
|
14 years ago
|
import Data.XML.Types(Element)
|
||
|
15 years ago
|
|
||
|
14 years ago
|
import Network.Xmpp.Monad
|
||
|
|
import Network.Xmpp.Pickle
|
||
|
|
import Network.Xmpp.Types
|
||
|
|
import Network.Xmpp.Concurrent
|
||
|
14 years ago
|
|
||
|
14 years ago
|
sessionXML :: Element
|
||
|
|
sessionXML = pickleElem
|
||
|
14 years ago
|
(xpElemBlank "{urn:ietf:params:xml:ns:xmpp-session}session")
|
||
|
|
()
|
||
|
14 years ago
|
|
||
|
14 years ago
|
sessionIQ :: Stanza
|
||
|
14 years ago
|
sessionIQ = IQRequestS $ IQRequest { iqRequestID = "sess"
|
||
|
|
, iqRequestFrom = Nothing
|
||
|
|
, iqRequestTo = Nothing
|
||
|
|
, iqRequestLangTag = Nothing
|
||
|
|
, iqRequestType = Set
|
||
|
|
, iqRequestPayload = sessionXML
|
||
|
|
}
|
||
|
15 years ago
|
|
||
|
14 years ago
|
-- Sends the session IQ set element and waits for an answer. Throws an error if
|
||
|
|
-- if an IQ error stanza is returned from the server.
|
||
|
14 years ago
|
xmppStartSession :: XmppConMonad ()
|
||
|
14 years ago
|
xmppStartSession = do
|
||
|
|
answer <- xmppSendIQ' "session" Nothing Set Nothing sessionXML
|
||
|
|
case answer of
|
||
|
|
Left e -> error $ show e
|
||
|
|
Right _ -> return ()
|
||
|
|
|
||
|
14 years ago
|
-- Sends the session IQ set element and waits for an answer. Throws an error if
|
||
|
|
-- if an IQ error stanza is returned from the server.
|
||
|
14 years ago
|
startSession :: Xmpp ()
|
||
|
14 years ago
|
startSession = do
|
||
|
|
answer <- sendIQ' Nothing Set Nothing sessionXML
|
||
|
|
case answer of
|
||
|
|
Left e -> error $ show e
|
||
|
|
Right _ -> return ()
|