]> git.rkrishnan.org Git - functorrent.git/commitdiff
WIP: msg loop to send/recv infodict
authorRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Sat, 12 Aug 2017 11:01:13 +0000 (16:31 +0530)
committerRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Sat, 12 Aug 2017 11:01:13 +0000 (16:31 +0530)
src/FuncTorrent/Peer.hs

index 4396c1c004bd5364c9a75deecb34b862d3c10dc7..1c6bf7f77472c00d94c2197e3dd3fa3c0d002b1d 100644 (file)
@@ -25,7 +25,7 @@ module FuncTorrent.Peer
 
 import Prelude hiding (lookup, concat, replicate, splitAt, take, drop)
 
-import Control.Concurrent.MVar (MVar, readMVar, putMVar, takeMVar)
+import Control.Concurrent.MVar (MVar, newEmptyMVar, readMVar, putMVar, takeMVar)
 import Control.Monad.State
 import Data.ByteString (ByteString, unpack, concat, hGet, hPut, take, drop, empty, singleton)
 import Data.Bits
@@ -71,6 +71,8 @@ doHandshake True h p infohash peerid = do
   putStrLn $ "--> handhake to peer: " ++ show p
   hsMsg <- hGet h (length (unpack hs))
   putStrLn $ "<-- handshake from peer: " ++ show p
+  infoPieceMap <- newEmptyMVar
+  metadataMsgLoop h $ InfoState infoPieceMap
   return ()
   -- if doesPeerSupportExtendedMsg hsMsg
   --   then