diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/dhtd.hs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs index 4f26fc16..b6680f2e 100644 --- a/examples/dhtd.hs +++ b/examples/dhtd.hs | |||
@@ -1412,17 +1412,16 @@ toxman announcer toxbkts tox presence = ToxManager | |||
1412 | let ContactInfo{ accounts } = Tox.toxContactInfo tox | 1412 | let ContactInfo{ accounts } = Tox.toxContactInfo tox |
1413 | pub = toPublic seckey | 1413 | pub = toPublic seckey |
1414 | pubid = Tox.key2id pub | 1414 | pubid = Tox.key2id pub |
1415 | (mcon,newlyActive) <- atomically $ do | 1415 | (acnt,newlyActive) <- atomically $ do |
1416 | macnt <- HashMap.lookup pubid <$> readTVar accounts | 1416 | macnt <- HashMap.lookup pubid <$> readTVar accounts |
1417 | acnt <- maybe (newAccount seckey) return macnt | 1417 | acnt <- maybe (newAccount seckey) return macnt |
1418 | rs <- readTVar $ clientRefs acnt | 1418 | rs <- readTVar $ clientRefs acnt |
1419 | writeTVar (clientRefs acnt) $! Set.insert k rs | 1419 | writeTVar (clientRefs acnt) $! Set.insert k rs |
1420 | modifyTVar accounts (HashMap.insert pubid acnt) | 1420 | modifyTVar accounts (HashMap.insert pubid acnt) |
1421 | mcon <- fmap ((,) acnt) . Map.lookup k <$> readTVar (keyToChan presence) | ||
1422 | if not (Set.null rs) | 1421 | if not (Set.null rs) |
1423 | then return (mcon,[]) | 1422 | then return (acnt,[]) |
1424 | else do | 1423 | else do |
1425 | fmap ((,) mcon) $ forM toxbkts $ \(nm,bkts) -> do | 1424 | fmap ((,) acnt) $ forM toxbkts $ \(nm,bkts) -> do |
1426 | akey <- packAnnounceKey announcer (nm ++ "id:" ++ show pubid) | 1425 | akey <- packAnnounceKey announcer (nm ++ "id:" ++ show pubid) |
1427 | return (akey,bkts) | 1426 | return (akey,bkts) |
1428 | forM_ newlyActive $ \(akey,bkts) -> do | 1427 | forM_ newlyActive $ \(akey,bkts) -> do |
@@ -1437,7 +1436,7 @@ toxman announcer toxbkts tox presence = ToxManager | |||
1437 | toxAnnounceInterval) | 1436 | toxAnnounceInterval) |
1438 | pub | 1437 | pub |
1439 | 1438 | ||
1440 | forM_ mcon $ \(acnt,conn) -> forkAccountWatcher acnt tox conn | 1439 | forkAccountWatcher acnt tox presence |
1441 | return () | 1440 | return () |
1442 | , deactivateAccount = \k pubname -> do | 1441 | , deactivateAccount = \k pubname -> do |
1443 | bStopped <- fmap (fromMaybe False) $ atomically $ do | 1442 | bStopped <- fmap (fromMaybe False) $ atomically $ do |