From 030fc2790db7f7c8b13521edd4bfaba2585647b2 Mon Sep 17 00:00:00 2001 From: Sam T Date: Wed, 17 Apr 2013 13:09:26 +0400 Subject: + Add constructors stubs. And organize exports a bit. --- src/Network/Torrent/Tracker.hs | 41 +++++++++++++++++++++++++++++++++++++---- 1 file 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 @@ {-# LANGUAGE OverloadedStrings #-} module Network.Torrent.Tracker ( module Network.Torrent.Tracker.Scrape - , Event(..), TRequest(..), TResponse(..) - , defaultRequest, defaultPorts + + -- * Requests + , Event(..), TRequest(..) + , startedReq, regularReq, stoppedReq, completedReq + , defaultRequest -- TODO remove export + + -- * Responses + , TResponse(..) , sendRequest + + -- * Extra + , defaultPorts ) where @@ -167,16 +176,40 @@ defaultRequest announce hash pid = , reqEvent = Just Started } +-- | The first request to the tracker that should be created is 'startedReq'. +-- It includes necessary 'Started' event field. +-- +startedReq :: TRequest +startedReq = undefined + +-- | Regular request must be sent to keep track new peers and +-- notify tracker about current state of the client +-- so new peers could connect to the client. +-- +regularReq :: TRequest +regularReq = undefined + +-- | Must be sent to the tracker if the client is shutting down gracefully. +-- +stoppedReq :: TRequest +stoppedReq = undefined + +-- | Must be sent to the tracker when the download completes. +-- However, must not be sent if the download was already 100% complete. +-- +completedReq :: TRequest +completedReq = undefined + + + -- | TODO rename to ask for peers -- sendRequest :: TRequest -> IO (Result TResponse) sendRequest req = do let r = mkHTTPRequest (encodeRequest req) - print r rawResp <- simpleHTTP r respBody <- getResponseBody rawResp - print respBody return (decoded (BC.pack respBody)) where -- cgit v1.2.3