summaryrefslogtreecommitdiff
path: root/Presence/main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Presence/main.hs')
-rw-r--r--Presence/main.hs10
1 files changed, 6 insertions, 4 deletions
diff --git a/Presence/main.hs b/Presence/main.hs
index 78ca4363..44af40e3 100644
--- a/Presence/main.hs
+++ b/Presence/main.hs
@@ -82,18 +82,19 @@ instance XMPPSession UnixSession where
82 L.putStrLn $ "SESSION: jid " <++> jid 82 L.putStrLn $ "SESSION: jid " <++> jid
83 return jid 83 return jid
84 closeSession _ = L.putStrLn "SESSION: close" 84 closeSession _ = L.putStrLn "SESSION: close"
85 subscribeToPresence session Nothing = do 85 subscribe session Nothing = do
86 let tmvar = greedySubscriber (presence_state session) 86 let tmvar = greedySubscriber (presence_state session)
87 chan <- atomically $ 87 chan <- atomically $
88 (do (cnt,chan) <- takeTMVar tmvar 88 (do (cnt,chan) <- takeTMVar tmvar
89 putTMVar tmvar (cnt+1,chan) 89 putTMVar tmvar (cnt+1,chan)
90 return chan ) 90 chan' <- dupTChan chan
91 return chan' )
91 `orElse` 92 `orElse`
92 (do chan <- newTChan 93 (do chan <- newTChan
93 putTMVar tmvar (1,chan) 94 putTMVar tmvar (1,chan)
94 return chan ) 95 return chan )
95 return chan 96 return chan
96 subscribeToPresence session (Just jid) = do 97 subscribe session (Just jid) = do
97 let tvar = subscriberMap (presence_state session) 98 let tvar = subscriberMap (presence_state session)
98 atomically $ do 99 atomically $ do
99 subs <- readTVar tvar 100 subs <- readTVar tvar
@@ -104,7 +105,8 @@ instance XMPPSession UnixSession where
104 newchan <- newTChan 105 newchan <- newTChan
105 return (newchan, Map.insert jid (1,newchan) subs) 106 return (newchan, Map.insert jid (1,newchan) subs)
106 Just (cnt,chan) -> do 107 Just (cnt,chan) -> do
107 return (chan, Map.insert jid (cnt+1,chan) subs) 108 chan' <- dupTChan chan
109 return (chan', Map.insert jid (cnt+1,chan) subs)
108 writeTVar tvar subs' 110 writeTVar tvar subs'
109 return chan 111 return chan
110 112