From bc5a84c34ba400f3d319387f34a7259923ca64e6 Mon Sep 17 00:00:00 2001 From: James Crayne Date: Thu, 14 Jun 2018 06:18:04 +0000 Subject: Experimental Connection.Tox integration --- Connection/Tox.hs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'Connection') diff --git a/Connection/Tox.hs b/Connection/Tox.hs index 5a9dc5eb..08a930bf 100644 --- a/Connection/Tox.hs +++ b/Connection/Tox.hs @@ -13,9 +13,9 @@ import Control.Monad import Data.Functor.Identity import qualified Data.Map as Map import Connection.Tox.Threads -import Network.Tox import Network.Tox.NodeId import Network.Tox.DHT.Handlers +import Network.Tox.Crypto.Handlers import PingMachine import Text.Read #ifdef THREAD_DEBUG @@ -31,16 +31,12 @@ import GHC.Conc (threadStatus,ThreadStatus(..)) data Parameters = Parameters { -- | Various Tox transports and clients. - toxTransports :: Tox + dhtRouting :: Routing -- | Thread to be forked when a connection is established. -- TODO: this function should accept relevant parameters. , onToxSession :: IO () } -data Key = Key NodeId{-me-} NodeId{-them-} - deriving (Eq,Ord) - -instance Show Key where show = show . showKey_ {- -- | A conneciton status that is tagged with a state type that is specific to @@ -165,7 +161,7 @@ setToxPolicy params conmap k policy = case policy of $ freshenContact getPolicy _get_status freshen_methods atomically $ do writeTVar (sessionTasks st) $ SessionTasks accepting persuing refreshing - let routing = toxRouting $ toxTransports params + let routing = dhtRouting params Key _ nid = k registerNodeCallback routing $ NodeInfoCallback { interestingNodeId = nid @@ -182,7 +178,7 @@ setToxPolicy params conmap k policy = case policy of -- Here we block until they finish. forM_ mst $ \st -> do atomically $ do - let routing = toxRouting $ toxTransports params + let routing = dhtRouting params Key _ nid = k unregisterNodeCallback callbackId routing nid atomically $ do @@ -201,7 +197,7 @@ setToxPolicy params conmap k policy = case policy of (G.InProgress $ toEnum 0) $ acceptContact getPolicy _accept_methods atomically $ do - let routing = toxRouting $ toxTransports params + let routing = dhtRouting params Key _ nid = k registerNodeCallback routing $ NodeInfoCallback { interestingNodeId = nid @@ -210,10 +206,6 @@ setToxPolicy params conmap k policy = case policy of , rumoredAddress = \saddr ni -> return () -- TODO } - -showKey_ :: Key -> String -showKey_ (Key me them) = show me ++ ":" ++ show them - stringToKey_ :: String -> Maybe Key stringToKey_ s = let (xs,ys) = break (==':') s in if null ys then Nothing -- cgit v1.2.3