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.
22 lines
694 B
22 lines
694 B
|
13 years ago
|
module Network.Xmpp.Concurrent.Channels.Basic where
|
||
|
|
|
||
|
|
import Control.Concurrent.STM
|
||
|
|
import Data.IORef
|
||
|
|
import Network.Xmpp.Concurrent.Channels.Types
|
||
|
|
import Network.Xmpp.Types
|
||
|
|
|
||
|
|
-- | Get a duplicate of the stanza channel
|
||
|
|
getStanzaChan :: CSession -> IO (TChan Stanza)
|
||
|
|
getStanzaChan session = atomically $ dupTChan (sShadow session)
|
||
|
|
|
||
|
|
-- | Send a stanza to the server.
|
||
|
|
sendStanza :: Stanza -> CSession -> IO ()
|
||
|
|
sendStanza a session = atomically $ writeTChan (outCh session) a
|
||
|
|
|
||
|
|
-- | Create a forked session object
|
||
|
|
forkCSession :: CSession -> IO CSession
|
||
|
|
forkCSession session = do
|
||
|
|
mCH' <- newIORef Nothing
|
||
|
|
pCH' <- newIORef Nothing
|
||
|
|
return $ session {messagesRef = mCH' , presenceRef = pCH'}
|