diff options
author | joe <joe@jerkface.net> | 2017-11-10 21:04:46 -0500 |
---|---|---|
committer | joe <joe@jerkface.net> | 2017-11-10 21:04:46 -0500 |
commit | 4f32bb5db83291713411a5b9d82f7989b719e709 (patch) | |
tree | bc296c79e4f4334fbb0eda6c0d45decd3d683501 | |
parent | 57b68ee93bd7a2c6d619ebafbe081703e3c3b8cc (diff) |
XMPP client now receives roster on request.
-rw-r--r-- | examples/dhtd.hs | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs index 025f957f..0996ffab 100644 --- a/examples/dhtd.hs +++ b/examples/dhtd.hs | |||
@@ -988,13 +988,13 @@ sensibleDefaults = Options | |||
988 | , ip6bt = True | 988 | , ip6bt = True |
989 | , ip6tox = True | 989 | , ip6tox = True |
990 | , dhtkey = Nothing | 990 | , dhtkey = Nothing |
991 | , verbosity = 0 | 991 | , verbosity = 1 |
992 | } | 992 | } |
993 | 993 | ||
994 | -- bt=<port>,tox=<port> | 994 | -- bt=<port>,tox=<port> |
995 | -- -4 | 995 | -- -4 |
996 | parseArgs :: [String] -> Options -> Options | 996 | parseArgs :: [String] -> Options -> Options |
997 | parseArgs [] opts = opts | 997 | parseArgs [] opts = opts |
998 | parseArgs ("--dhtkey":k:args) opts = parseArgs args opts | 998 | parseArgs ("--dhtkey":k:args) opts = parseArgs args opts |
999 | { dhtkey = decodeSecret $ B.pack k } | 999 | { dhtkey = decodeSecret $ B.pack k } |
1000 | parseArgs ("-4":args) opts = parseArgs args opts | 1000 | parseArgs ("-4":args) opts = parseArgs args opts |
@@ -1329,7 +1329,7 @@ main = do | |||
1329 | srv <- streamServer (withSession session) (SockAddrUnix "dht.sock") | 1329 | srv <- streamServer (withSession session) (SockAddrUnix "dht.sock") |
1330 | return ( do atomically $ readTVar signalQuit >>= check | 1330 | return ( do atomically $ readTVar signalQuit >>= check |
1331 | quitListening srv | 1331 | quitListening srv |
1332 | , readTVar signalQuit | 1332 | , readTVar signalQuit >>= check |
1333 | ) | 1333 | ) |
1334 | 1334 | ||
1335 | 1335 | ||
@@ -1359,8 +1359,14 @@ main = do | |||
1359 | -- XMPP stanza handling | 1359 | -- XMPP stanza handling |
1360 | runResourceT $ do | 1360 | runResourceT $ do |
1361 | sv <- xmppServer (presenceHooks state (verbosity opts)) | 1361 | sv <- xmppServer (presenceHooks state (verbosity opts)) |
1362 | -- We now have a server object but it's not ready to use until | ||
1363 | -- we put it into the 'server' field of our /state/ record. | ||
1362 | 1364 | ||
1363 | fork $ liftIO $ do | 1365 | liftIO $ do |
1366 | atomically $ putTMVar (server state) sv -- Okay, now it's ready. :) | ||
1367 | -- FIXME: This is error prone. | ||
1368 | |||
1369 | forkIO $ do | ||
1364 | myThreadId >>= flip labelThread "XMPP.stanzas" | 1370 | myThreadId >>= flip labelThread "XMPP.stanzas" |
1365 | let console = cwPresenceChan $ consoleWriter state | 1371 | let console = cwPresenceChan $ consoleWriter state |
1366 | fix $ \loop -> do | 1372 | fix $ \loop -> do |
@@ -1371,9 +1377,11 @@ main = do | |||
1371 | (checkQuit >> return (return ())) | 1377 | (checkQuit >> return (return ())) |
1372 | what | 1378 | what |
1373 | 1379 | ||
1380 | hPutStrLn stderr "Started XMPP server." | ||
1381 | |||
1374 | -- Wait for DHT and XMPP threads to finish. | 1382 | -- Wait for DHT and XMPP threads to finish. |
1375 | -- Use ResourceT to clean-up XMPP server. | 1383 | -- Use ResourceT to clean-up XMPP server. |
1376 | liftIO waitForSignal | 1384 | waitForSignal |
1377 | 1385 | ||
1378 | stopAnnouncer announcer | 1386 | stopAnnouncer announcer |
1379 | quitBt | 1387 | quitBt |