From: Ramakrishnan Muthukrishnan Date: Fri, 18 Sep 2015 07:04:52 +0000 (+0530) Subject: handle Choke, interested, notinterested, cancel and port msgs X-Git-Url: https://git.rkrishnan.org/quickstart.html?a=commitdiff_plain;h=5ad7d5cb250a61b3a889373d86d72a09c3f5ce22;p=functorrent.git handle Choke, interested, notinterested, cancel and port msgs --- diff --git a/src/FuncTorrent/Peer.hs b/src/FuncTorrent/Peer.hs index ed88e83..e4a5349 100644 --- a/src/FuncTorrent/Peer.hs +++ b/src/FuncTorrent/Peer.hs @@ -201,6 +201,21 @@ msgLoop pieceStatus file = do UnChokeMsg -> do modify (\st -> st {heChoking = False }) msgLoop pieceStatus file + ChokeMsg -> do + modify (\st -> st {heChoking = True }) + msgLoop pieceStatus file + InterestedMsg -> do + modify (\st -> st {heInterested = True}) + msgLoop pieceStatus file + NotInterestedMsg -> do + modify (\st -> st {heInterested = False}) + msgLoop pieceStatus file + CancelMsg _ _ _ -> do -- check if valid index, begin, length + msgLoop pieceStatus file + PortMsg _ -> do + msgLoop pieceStatus file + -- handle RequestMsg, HaveMsg. No need to handle PieceMsg here. + -- also BitFieldMsg downloadPiece :: Handle -> Integer -> Integer -> IO ByteString