import FuncTorrent.Tracker.Types (TState(..), TrackerEventState(..), TrackerProtocol(..), TrackerMsg(..))
import FuncTorrent.Utils (Port, toPort, getHostname)
import qualified FuncTorrent.FileSystem as FS (MsgChannel)
-import FuncTorrent.Peer (Peer)
+import FuncTorrent.PeerMsgs (Peer)
type MsgChannel = Chan TrackerMsg
host = getHostname turl
case getTrackerType turl of
Http -> do
- _ <- forkIO $ HT.trackerLoop host port peerId infohash fsChan initialTState
+ _ <- forkIO $ HT.trackerLoop turl port peerId infohash fsChan initialTState
runStateT (msgHandler msgChannel) initialTState
return ()
Udp -> do
_ <- forkIO $ UT.trackerLoop turl (fromIntegral port) peerId infohash fsChan initialTState
+ runStateT (msgHandler msgChannel) initialTState
return ()
_ ->
error "Tracker Protocol unimplemented"
getTrackerType :: String -> TrackerProtocol
getTrackerType url | "http://" `isPrefixOf` url = Http
| "udp://" `isPrefixOf` url = Udp
- | otherwise = UnknownProtocol
+ | otherwise = UnknownProtocol
msgHandler :: MsgChannel -> StateT TState IO ()