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