diff options
author | Sam T <sta.cs.vsu@gmail.com> | 2013-04-17 13:09:26 +0400 |
---|---|---|
committer | Sam T <sta.cs.vsu@gmail.com> | 2013-04-17 13:09:26 +0400 |
commit | 030fc2790db7f7c8b13521edd4bfaba2585647b2 (patch) | |
tree | fea70b5e398c678cc8af43d2e51dd11642692166 /src/Network/Torrent | |
parent | 9e932d508dfd237e22f5a6dd6a351bae646c54e5 (diff) |
+ Add constructors stubs.
And organize exports a bit.
Diffstat (limited to 'src/Network/Torrent')
-rw-r--r-- | src/Network/Torrent/Tracker.hs | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/src/Network/Torrent/Tracker.hs b/src/Network/Torrent/Tracker.hs index 20cdb2fc..9c925c0f 100644 --- a/src/Network/Torrent/Tracker.hs +++ b/src/Network/Torrent/Tracker.hs | |||
@@ -2,9 +2,18 @@ | |||
2 | {-# LANGUAGE OverloadedStrings #-} | 2 | {-# LANGUAGE OverloadedStrings #-} |
3 | module Network.Torrent.Tracker | 3 | module Network.Torrent.Tracker |
4 | ( module Network.Torrent.Tracker.Scrape | 4 | ( module Network.Torrent.Tracker.Scrape |
5 | , Event(..), TRequest(..), TResponse(..) | 5 | |
6 | , defaultRequest, defaultPorts | 6 | -- * Requests |
7 | , Event(..), TRequest(..) | ||
8 | , startedReq, regularReq, stoppedReq, completedReq | ||
9 | , defaultRequest -- TODO remove export | ||
10 | |||
11 | -- * Responses | ||
12 | , TResponse(..) | ||
7 | , sendRequest | 13 | , sendRequest |
14 | |||
15 | -- * Extra | ||
16 | , defaultPorts | ||
8 | ) | 17 | ) |
9 | where | 18 | where |
10 | 19 | ||
@@ -167,16 +176,40 @@ defaultRequest announce hash pid = | |||
167 | , reqEvent = Just Started | 176 | , reqEvent = Just Started |
168 | } | 177 | } |
169 | 178 | ||
179 | -- | The first request to the tracker that should be created is 'startedReq'. | ||
180 | -- It includes necessary 'Started' event field. | ||
181 | -- | ||
182 | startedReq :: TRequest | ||
183 | startedReq = undefined | ||
184 | |||
185 | -- | Regular request must be sent to keep track new peers and | ||
186 | -- notify tracker about current state of the client | ||
187 | -- so new peers could connect to the client. | ||
188 | -- | ||
189 | regularReq :: TRequest | ||
190 | regularReq = undefined | ||
191 | |||
192 | -- | Must be sent to the tracker if the client is shutting down gracefully. | ||
193 | -- | ||
194 | stoppedReq :: TRequest | ||
195 | stoppedReq = undefined | ||
196 | |||
197 | -- | Must be sent to the tracker when the download completes. | ||
198 | -- However, must not be sent if the download was already 100% complete. | ||
199 | -- | ||
200 | completedReq :: TRequest | ||
201 | completedReq = undefined | ||
202 | |||
203 | |||
204 | |||
170 | -- | TODO rename to ask for peers | 205 | -- | TODO rename to ask for peers |
171 | -- | 206 | -- |
172 | sendRequest :: TRequest -> IO (Result TResponse) | 207 | sendRequest :: TRequest -> IO (Result TResponse) |
173 | sendRequest req = do | 208 | sendRequest req = do |
174 | let r = mkHTTPRequest (encodeRequest req) | 209 | let r = mkHTTPRequest (encodeRequest req) |
175 | print r | ||
176 | 210 | ||
177 | rawResp <- simpleHTTP r | 211 | rawResp <- simpleHTTP r |
178 | respBody <- getResponseBody rawResp | 212 | respBody <- getResponseBody rawResp |
179 | print respBody | ||
180 | return (decoded (BC.pack respBody)) | 213 | return (decoded (BC.pack respBody)) |
181 | 214 | ||
182 | where | 215 | where |