diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2013-12-05 23:50:08 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2013-12-05 23:50:08 +0400 |
commit | 34d2d93d2906b7627133a8f1c8f6dda4aee2f796 (patch) | |
tree | e74e26be98fcf74440e5065567d19a32dba36419 | |
parent | abec3de25b40d23627396d3eb98d1af547cf546c (diff) |
Add keep alive interval constant
-rw-r--r-- | src/Network/BitTorrent/Exchange/Message.hs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/Network/BitTorrent/Exchange/Message.hs b/src/Network/BitTorrent/Exchange/Message.hs index eccffc77..f29dec10 100644 --- a/src/Network/BitTorrent/Exchange/Message.hs +++ b/src/Network/BitTorrent/Exchange/Message.hs | |||
@@ -48,6 +48,7 @@ module Network.BitTorrent.Exchange.Message | |||
48 | -- * Messages | 48 | -- * Messages |
49 | , Message (..) | 49 | , Message (..) |
50 | , PeerMessage (..) | 50 | , PeerMessage (..) |
51 | , defaultKeepAliveInterval | ||
51 | 52 | ||
52 | -- ** Core messages | 53 | -- ** Core messages |
53 | , StatusUpdate (..) | 54 | , StatusUpdate (..) |
@@ -581,9 +582,9 @@ type MessageId = Word8 | |||
581 | data Message | 582 | data Message |
582 | -- | Peers may close the TCP connection if they have not received | 583 | -- | Peers may close the TCP connection if they have not received |
583 | -- any messages for a given period of time, generally 2 | 584 | -- any messages for a given period of time, generally 2 |
584 | -- minutes. Thus, the "keep-alive" message is sent tot keep the | 585 | -- minutes. Thus, the KeepAlive message is sent to keep the |
585 | -- connection between two peers alive, if no /other/ message has | 586 | -- connection between two peers alive, if no /other/ message has |
586 | -- been sentin a given period of time. | 587 | -- been sent in a given period of time. |
587 | = KeepAlive | 588 | = KeepAlive |
588 | | Status !StatusUpdate | 589 | | Status !StatusUpdate |
589 | | Regular !RegularMessage | 590 | | Regular !RegularMessage |
@@ -623,6 +624,10 @@ instance PeerMessage PortNumber where | |||
623 | requires _ = Just ExtDHT | 624 | requires _ = Just ExtDHT |
624 | {-# INLINE requires #-} | 625 | {-# INLINE requires #-} |
625 | 626 | ||
627 | -- | In seconds. | ||
628 | defaultKeepAliveInterval :: Int | ||
629 | defaultKeepAliveInterval = 2 * 60 | ||
630 | |||
626 | getInt :: S.Get Int | 631 | getInt :: S.Get Int |
627 | getInt = fromIntegral <$> S.getWord32be | 632 | getInt = fromIntegral <$> S.getWord32be |
628 | {-# INLINE getInt #-} | 633 | {-# INLINE getInt #-} |