diff options
author | Sam T <pxqr.sta@gmail.com> | 2013-06-11 05:01:40 +0400 |
---|---|---|
committer | Sam T <pxqr.sta@gmail.com> | 2013-06-11 05:01:40 +0400 |
commit | eba89394fa87256fd2ec71b67e667032e9e765dd (patch) | |
tree | 45d97e83bcdc05a9a51cec2edffe256949df1426 | |
parent | 64de83063c21a963b9c7cdec82cfe2b036166c15 (diff) |
~ Add exsamples.
-rw-r--r-- | bittorrent.cabal | 5 | ||||
-rw-r--r-- | exsamples/Main.hs | 20 |
2 files changed, 25 insertions, 0 deletions
diff --git a/bittorrent.cabal b/bittorrent.cabal index 6266b63b..b4da98a4 100644 --- a/bittorrent.cabal +++ b/bittorrent.cabal | |||
@@ -102,6 +102,11 @@ library | |||
102 | cpp-options: -DTESTING | 102 | cpp-options: -DTESTING |
103 | ghc-options: -Wall | 103 | ghc-options: -Wall |
104 | 104 | ||
105 | executable exsample | ||
106 | main-is: Main.hs | ||
107 | hs-source-dirs: exsamples | ||
108 | build-depends: base == 4.* | ||
109 | , bittorrent | ||
105 | 110 | ||
106 | 111 | ||
107 | test-suite info-hash | 112 | test-suite info-hash |
diff --git a/exsamples/Main.hs b/exsamples/Main.hs new file mode 100644 index 00000000..3a347ab6 --- /dev/null +++ b/exsamples/Main.hs | |||
@@ -0,0 +1,20 @@ | |||
1 | module Main (main) where | ||
2 | |||
3 | import Data.Bitfield | ||
4 | import Network.BitTorrent | ||
5 | import System.Environment | ||
6 | |||
7 | |||
8 | main :: IO () | ||
9 | main = do | ||
10 | [path] <- getArgs | ||
11 | Right torrent <- fromFile path | ||
12 | |||
13 | client <- newClient [] | ||
14 | swarm <- newLeacher client torrent | ||
15 | |||
16 | discover swarm $ \se -> do | ||
17 | peers <- getPeerList se | ||
18 | print peers | ||
19 | |||
20 | print "Bye-bye!" \ No newline at end of file | ||