summaryrefslogtreecommitdiff
path: root/examples/dhtd.hs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/dhtd.hs')
-rw-r--r--examples/dhtd.hs16
1 files changed, 14 insertions, 2 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs
index 04de4056..8fc986a5 100644
--- a/examples/dhtd.hs
+++ b/examples/dhtd.hs
@@ -1078,8 +1078,20 @@ toxman tox = ToxManager
1078 -- Stop the recurring search for that contact 1078 -- Stop the recurring search for that contact
1079 return () 1079 return ()
1080 , setToxConnectionPolicy = \me them -> \case 1080 , setToxConnectionPolicy = \me them -> \case
1081 TryingToConnect -> return () -- Add a contact. 1081 TryingToConnect -> do
1082 _ -> return () -- Remove contact. 1082 let db@ContactInfo{ accounts } = Tox.toxContactInfo tox
1083 sequence_ $ do
1084 meid <- readMaybe $ T.unpack $ T.take 43 me
1085 themid <- readMaybe $ T.unpack $ T.take 43 them
1086 Just $ atomically $ do
1087 accs <- readTVar accounts
1088 case HashMap.lookup meid accs of
1089 Nothing -> return () -- Unknown account.
1090 Just acc -> modifyTVar' (contacts acc)
1091 $ HashMap.alter (mergeContact nullContact { contactPolicy = Just TryingToConnect })
1092 themid
1093 -- If unscheduled and unconnected, schedule recurring search for this contact.
1094 _ -> return () -- Remove contact.
1083 } 1095 }
1084 1096
1085#ifdef XMPP 1097#ifdef XMPP