diff options
author | Sam T <pxqr.sta@gmail.com> | 2013-06-11 07:52:20 +0400 |
---|---|---|
committer | Sam T <pxqr.sta@gmail.com> | 2013-06-11 07:52:20 +0400 |
commit | 0254b200cd4aa5245c37c7a650f8b14567a3b4cf (patch) | |
tree | 13ed575f9ffa3cb9e1dbd39b51fc48845125ea5a /src/Network/BitTorrent/Internal.hs | |
parent | 1b4fdf35dd6c21d600130c42a1bcb5c56b25afa6 (diff) |
~ Minor changes.
Diffstat (limited to 'src/Network/BitTorrent/Internal.hs')
-rw-r--r-- | src/Network/BitTorrent/Internal.hs | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/Network/BitTorrent/Internal.hs b/src/Network/BitTorrent/Internal.hs index e231fb2c..39e10ce2 100644 --- a/src/Network/BitTorrent/Internal.hs +++ b/src/Network/BitTorrent/Internal.hs | |||
@@ -85,11 +85,16 @@ instance Ord ClientSession where | |||
85 | compare = comparing clientPeerID | 85 | compare = comparing clientPeerID |
86 | 86 | ||
87 | newClient :: [Extension] -> IO ClientSession | 87 | newClient :: [Extension] -> IO ClientSession |
88 | newClient exts = ClientSession <$> newPeerID | 88 | newClient exts = do |
89 | <*> pure exts | 89 | mgr <- Ev.new |
90 | <*> newTVarIO S.empty | 90 | forkIO $ loop mgr |
91 | <*> Ev.new | 91 | |
92 | <*> newIORef (startProgress 0) | 92 | ClientSession |
93 | <$> newPeerID | ||
94 | <*> pure exts | ||
95 | <*> newTVarIO S.empty | ||
96 | <*> pure mgr | ||
97 | <*> newIORef (startProgress 0) | ||
93 | 98 | ||
94 | {----------------------------------------------------------------------- | 99 | {----------------------------------------------------------------------- |
95 | Swarm session | 100 | Swarm session |
@@ -207,7 +212,7 @@ maxIncomingTime :: Int | |||
207 | maxIncomingTime = 120 * sec | 212 | maxIncomingTime = 120 * sec |
208 | 213 | ||
209 | maxOutcomingTime :: Int | 214 | maxOutcomingTime :: Int |
210 | maxOutcomingTime = 60 * sec | 215 | maxOutcomingTime = 1 * sec |
211 | 216 | ||
212 | -- | Should be called after we have received any message from a peer. | 217 | -- | Should be called after we have received any message from a peer. |
213 | updateIncoming :: PeerSession -> IO () | 218 | updateIncoming :: PeerSession -> IO () |
@@ -221,8 +226,13 @@ updateOutcoming PeerSession {..} = | |||
221 | updateTimeout (eventManager (clientSession swarmSession)) | 226 | updateTimeout (eventManager (clientSession swarmSession)) |
222 | outcomingTimeout maxOutcomingTime | 227 | outcomingTimeout maxOutcomingTime |
223 | 228 | ||
224 | sendKA :: Socket -> IO () | 229 | sendKA :: Socket -> SwarmSession -> IO () |
225 | sendKA sock = sendAll sock (encode BT.KeepAlive) | 230 | sendKA sock SwarmSession {..} = do |
231 | print "I'm sending keep alive." | ||
232 | sendAll sock (encode BT.KeepAlive) | ||
233 | let mgr = eventManager clientSession | ||
234 | updateTimeout mgr | ||
235 | print "Done.." | ||
226 | 236 | ||
227 | abortSession :: IO () | 237 | abortSession :: IO () |
228 | abortSession = error "abortSession: not implemented" | 238 | abortSession = error "abortSession: not implemented" |