diff options
Diffstat (limited to 'src/Network/Tox/Crypto')
-rw-r--r-- | src/Network/Tox/Crypto/Handlers.hs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/Network/Tox/Crypto/Handlers.hs b/src/Network/Tox/Crypto/Handlers.hs index 50dd8c67..ef7afe98 100644 --- a/src/Network/Tox/Crypto/Handlers.hs +++ b/src/Network/Tox/Crypto/Handlers.hs | |||
@@ -3,6 +3,7 @@ | |||
3 | {-# LANGUAGE TypeOperators #-} | 3 | {-# LANGUAGE TypeOperators #-} |
4 | module Network.Tox.Crypto.Handlers where | 4 | module Network.Tox.Crypto.Handlers where |
5 | 5 | ||
6 | import Network.QueryResponse | ||
6 | import Network.Tox.NodeId | 7 | import Network.Tox.NodeId |
7 | import Network.Tox.Crypto.Transport | 8 | import Network.Tox.Crypto.Transport |
8 | import Network.Tox.DHT.Transport (Cookie(..),CookieData(..), CookieRequest(..), NoSpam(..)) | 9 | import Network.Tox.DHT.Transport (Cookie(..),CookieData(..), CookieRequest(..), NoSpam(..)) |
@@ -127,6 +128,7 @@ data NetCryptoSessions = NCSessions | |||
127 | , outboundQueueCapacity :: Word32 | 128 | , outboundQueueCapacity :: Word32 |
128 | , nextSessionId :: TVar SessionID | 129 | , nextSessionId :: TVar SessionID |
129 | , announceNewSessionHooks :: TVar [IOHook (Maybe NoSpam) NetCryptoSession] | 130 | , announceNewSessionHooks :: TVar [IOHook (Maybe NoSpam) NetCryptoSession] |
131 | , sessionTransport :: Transport String SockAddr NetCrypto | ||
130 | } | 132 | } |
131 | 133 | ||
132 | type NewSessionHook = IOHook (Maybe NoSpam) NetCryptoSession | 134 | type NewSessionHook = IOHook (Maybe NoSpam) NetCryptoSession |
@@ -190,6 +192,7 @@ newSessionsState crypto unrechook hooks = do | |||
190 | , outboundQueueCapacity = 400 | 192 | , outboundQueueCapacity = 400 |
191 | , nextSessionId = nextSessionId0 | 193 | , nextSessionId = nextSessionId0 |
192 | , announceNewSessionHooks = announceNewSessionHooks0 | 194 | , announceNewSessionHooks = announceNewSessionHooks0 |
195 | , sessionTransport = error "Need to set sessionTransport field of NetCryptoSessions!" | ||
193 | } | 196 | } |
194 | 197 | ||
195 | data HandshakeParams | 198 | data HandshakeParams |
@@ -376,6 +379,14 @@ freshCryptoSession sessions | |||
376 | cd <- atomically $ PQ.dequeue pktq | 379 | cd <- atomically $ PQ.dequeue pktq |
377 | _ <- runCryptoHook (netCryptoSession0 {ncDequeueThread=Just tid}) cd | 380 | _ <- runCryptoHook (netCryptoSession0 {ncDequeueThread=Just tid}) cd |
378 | loop | 381 | loop |
382 | -- launch dequeueOutgoing thread | ||
383 | threadidOutgoing <- forkIO $ do | ||
384 | tid <- myThreadId | ||
385 | labelThread tid ("NetCryptoDequeueOutgoing." ++ show (key2id remotePublicKey)) | ||
386 | fix $ \loop -> do | ||
387 | (_,pkt) <- atomically $ PQ.dequeueOutgoing pktoq | ||
388 | sendMessage (sessionTransport sessions) addr (NetCrypto pkt) | ||
389 | loop | ||
379 | -- launch ping thread | 390 | -- launch ping thread |
380 | fuzz <- randomRIO (0,2000) | 391 | fuzz <- randomRIO (0,2000) |
381 | pingMachine <- forkPingMachine ("NetCrypto." ++ show (key2id remotePublicKey)) (15000 + fuzz) 2000 | 392 | pingMachine <- forkPingMachine ("NetCrypto." ++ show (key2id remotePublicKey)) (15000 + fuzz) 2000 |