From 5ad7d5cb250a61b3a889373d86d72a09c3f5ce22 Mon Sep 17 00:00:00 2001
From: Ramakrishnan Muthukrishnan <ram@rkrishnan.org>
Date: Fri, 18 Sep 2015 12:34:52 +0530
Subject: [PATCH] handle Choke, interested, notinterested, cancel and port msgs

---
 src/FuncTorrent/Peer.hs | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

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
-- 
2.45.2