summaryrefslogtreecommitdiff
path: root/dht/src/Network/Tox/AggregateSession.hs
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-12-14 01:03:07 -0500
committerJoe Crayne <joe@jerkface.net>2020-01-01 23:26:05 -0500
commitb5a3c7b92e7effcd234037241b00f9f29773d870 (patch)
tree4047e11c9102585001dd3be95855038a6816a5c2 /dht/src/Network/Tox/AggregateSession.hs
parent97043e1069e172a0f389610610892ca060f395dd (diff)
STM-based awaitMessage.
Diffstat (limited to 'dht/src/Network/Tox/AggregateSession.hs')
-rw-r--r--dht/src/Network/Tox/AggregateSession.hs12
1 files changed, 6 insertions, 6 deletions
diff --git a/dht/src/Network/Tox/AggregateSession.hs b/dht/src/Network/Tox/AggregateSession.hs
index 8c728660..999c7399 100644
--- a/dht/src/Network/Tox/AggregateSession.hs
+++ b/dht/src/Network/Tox/AggregateSession.hs
@@ -188,21 +188,21 @@ forkSession c s setStatus = forkIO $ do
188 now <- getPOSIXTime 188 now <- getPOSIXTime
189 atomically $ modifyTVar' q $ PSQ.insert (fromEnum DoTimeout) (now + 15) 189 atomically $ modifyTVar' q $ PSQ.insert (fromEnum DoTimeout) (now + 15)
190 190
191 onPacket body loop Nothing = return () 191 onPacket body loop Terminated = return ()
192 onPacket body loop (Just (Left e)) = inPrint e >> loop 192 onPacket body loop (ParseError e) = inPrint e >> loop
193 onPacket body loop (Just (Right x)) = body loop x 193 onPacket body loop (Arrival _ x) = body loop x
194 194
195 awaitPacket body = fix $ awaitMessage (sTransport s) . onPacket body 195 awaitPacket body = fix $ join . atomically . awaitMessage (sTransport s) . onPacket body
196 196
197 atomically $ setStatus $ InProgress AwaitingSessionPacket 197 atomically $ setStatus $ InProgress AwaitingSessionPacket
198 awaitPacket $ \_ (online,()) -> do 198 awaitPacket $ \_ online -> do
199 when (msgID online /= M ONLINE) $ do 199 when (msgID online /= M ONLINE) $ do
200 inPrint $ "Unexpected initial packet: " ++ show (msgID online) 200 inPrint $ "Unexpected initial packet: " ++ show (msgID online)
201 atomically $ do setStatus Established 201 atomically $ do setStatus Established
202 sendPacket online 202 sendPacket online
203 bump 203 bump
204 beacon <- forkIO $ keepAlive s q 204 beacon <- forkIO $ keepAlive s q
205 awaitPacket $ \awaitNext (x,()) -> do 205 awaitPacket $ \awaitNext x -> do
206 bump 206 bump
207 case msgID x of 207 case msgID x of
208 M ALIVE -> return () 208 M ALIVE -> return ()