diff options
Diffstat (limited to 'src/Network/BitTorrent/Exchange.hs')
-rw-r--r-- | src/Network/BitTorrent/Exchange.hs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/Network/BitTorrent/Exchange.hs b/src/Network/BitTorrent/Exchange.hs index 2eedc6bd..3d05f7fc 100644 --- a/src/Network/BitTorrent/Exchange.hs +++ b/src/Network/BitTorrent/Exchange.hs | |||
@@ -58,6 +58,7 @@ module Network.BitTorrent.Exchange | |||
58 | , Event(..) | 58 | , Event(..) |
59 | , awaitEvent | 59 | , awaitEvent |
60 | , yieldEvent | 60 | , yieldEvent |
61 | , handleEvent | ||
61 | 62 | ||
62 | -- * Exceptions | 63 | -- * Exceptions |
63 | , disconnect | 64 | , disconnect |
@@ -444,6 +445,10 @@ yieldEvent (Fragment blk) = do | |||
444 | then yieldMessage (Piece blk) | 445 | then yieldMessage (Piece blk) |
445 | else return () | 446 | else return () |
446 | 447 | ||
448 | |||
449 | handleEvent :: (Event -> P2P Event) -> P2P () | ||
450 | handleEvent action = awaitEvent >>= action >>= yieldEvent | ||
451 | |||
447 | --flushBroadcast :: P2P () | 452 | --flushBroadcast :: P2P () |
448 | --flushBroadcast = nextBroadcast >>= maybe (return ()) go | 453 | --flushBroadcast = nextBroadcast >>= maybe (return ()) go |
449 | -- where | 454 | -- where |