diff options
author | Joe Crayne <joe@jerkface.net> | 2018-09-09 02:32:20 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2018-10-03 06:49:55 -0400 |
commit | fbf9890a6bcd4e6212b5947f908bc34f233b279d (patch) | |
tree | 1ceee1e2dcc2a1bb53c6ca03d0d4986099381630 /examples/dhtd.hs | |
parent | 037508fe7ed09e3b4f4c00b7778f6c0dc4a3d5f9 (diff) |
Moved resolving duty to Connection manager.
Diffstat (limited to 'examples/dhtd.hs')
-rw-r--r-- | examples/dhtd.hs | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs index 34b555f5..d397730b 100644 --- a/examples/dhtd.hs +++ b/examples/dhtd.hs | |||
@@ -2009,8 +2009,7 @@ main = do | |||
2009 | sport <- getBindAddress (portxmppS opts) True{-IPv6 supported-} | 2009 | sport <- getBindAddress (portxmppS opts) True{-IPv6 supported-} |
2010 | 2010 | ||
2011 | -- XMPP initialization | 2011 | -- XMPP initialization |
2012 | cw <- newConsoleWriter | 2012 | cw <- newConsoleWriter |
2013 | serverVar <- atomically $ newEmptyTMVar | ||
2014 | let lookupBkts :: String -> Map.Map String DHT -> Maybe (String,TVar (BucketList Tox.NodeInfo)) | 2013 | let lookupBkts :: String -> Map.Map String DHT -> Maybe (String,TVar (BucketList Tox.NodeInfo)) |
2015 | lookupBkts name m = case Map.lookup name m of | 2014 | lookupBkts name m = case Map.lookup name m of |
2016 | Nothing -> Nothing | 2015 | Nothing -> Nothing |
@@ -2020,16 +2019,12 @@ main = do | |||
2020 | , lookupBkts "tox6" toxdhts | 2019 | , lookupBkts "tox6" toxdhts |
2021 | ] | 2020 | ] |
2022 | 2021 | ||
2022 | sv <- xmppServer Tcp.noCleanUp (Just sport) | ||
2023 | tcp <- xmppConnections sv -- :: IO ( Manager TCPStatus T.Text ) | ||
2023 | let tman = toxman ssvar announcer toxbkts <$> mbtox | 2024 | let tman = toxman ssvar announcer toxbkts <$> mbtox |
2024 | state <- newPresenceState cw tman serverVar | 2025 | state <- newPresenceState cw tman sv (const tcp) |
2025 | 2026 | forkXmpp sv (presenceHooks state (verbosity opts) (Just cport) (Just sport)) | |
2026 | sv <- xmppServer Tcp.noCleanUp (presenceHooks state (verbosity opts) (Just cport) (Just sport)) | ||
2027 | -- We now have a server object but it's not ready to use until | ||
2028 | -- we put it into the 'server' field of our /state/ record. | ||
2029 | conns <- xmppConnections sv | 2027 | conns <- xmppConnections sv |
2030 | atomically $ do | ||
2031 | putTMVar serverVar (sv,conns) -- Okay, now it's ready. :) | ||
2032 | -- FIXME: This is error prone. | ||
2033 | return (Just sv, Just conns, Just state) | 2028 | return (Just sv, Just conns, Just state) |
2034 | 2029 | ||
2035 | forM_ (take 1 taddrs) $ \addrTox -> do | 2030 | forM_ (take 1 taddrs) $ \addrTox -> do |
@@ -2151,8 +2146,7 @@ main = do | |||
2151 | -- Use ResourceT to clean-up XMPP server. | 2146 | -- Use ResourceT to clean-up XMPP server. |
2152 | waitForSignal | 2147 | waitForSignal |
2153 | 2148 | ||
2154 | forM_ mstate $ \PresenceState{server=tmvar} -> do | 2149 | forM_ mstate $ \PresenceState{server=xmpp} -> do |
2155 | xmpp <- fst <$> atomically (readTMVar tmvar) | ||
2156 | quitXmpp xmpp | 2150 | quitXmpp xmpp |
2157 | stopAnnouncer announcer | 2151 | stopAnnouncer announcer |
2158 | quitBt | 2152 | quitBt |