Browse Source

Merge branch 'master' of git://github.com/Philonous/pontarius

master
Jon Kristensen 13 years ago
parent
commit
cc7c98e00a
  1. 3
      source/Network/Xmpp/Concurrent.hs
  2. 6
      source/Network/Xmpp/Types.hs

3
source/Network/Xmpp/Concurrent.hs

@ -113,12 +113,13 @@ newSession stream config = runErrorT $ do @@ -113,12 +113,13 @@ newSession stream config = runErrorT $ do
]
(kill, wLock, streamState, readerThread) <- ErrorT $ startThreadsWith stanzaHandler eh stream
writer <- lift $ forkIO $ writeWorker outC wLock
idGen <- liftIO $ sessionStanzaIDs config
return $ Session { stanzaCh = stanzaChan
, outCh = outC
, iqHandlers = iqHandlers
, writeRef = wLock
, readerThread = readerThread
, idGenerator = sessionStanzaIDs config
, idGenerator = idGen
, streamRef = streamState
, eventHandlers = eh
, stopThreads = kill >> killThread writer

6
source/Network/Xmpp/Types.hs

@ -1100,7 +1100,7 @@ data SessionConfiguration = SessionConfiguration @@ -1100,7 +1100,7 @@ data SessionConfiguration = SessionConfiguration
-- | Handler to be run when the session ends (for whatever reason).
, sessionClosedHandler :: XmppFailure -> IO ()
-- | Function to generate the stream of stanza identifiers.
, sessionStanzaIDs :: IO StanzaID
, sessionStanzaIDs :: IO (IO StanzaID)
, extraStanzaHandlers :: [StanzaHandler]
}
@ -1109,10 +1109,10 @@ instance Default SessionConfiguration where @@ -1109,10 +1109,10 @@ instance Default SessionConfiguration where
, sessionClosedHandler = \_ -> return ()
, sessionStanzaIDs = do
idRef <- newTVarIO 1
atomically $ do
return . atomically $ do
curId <- readTVar idRef
writeTVar idRef (curId + 1 :: Integer)
return . read. show $ curId
return . StanzaID . Text.pack . show $ curId
, extraStanzaHandlers = []
}

Loading…
Cancel
Save