Permalink
Browse files

Leacher with output

  • Loading branch information...
1 parent 0e0e131 commit 820ecfa6ee5401caaf5484dbacc1bb8b1c81ed97 @kthakore committed Oct 1, 2012
Showing with 20 additions and 4 deletions.
  1. +20 −4 simple_client.cpp
View
24 simple_client.cpp
@@ -8,6 +8,7 @@
#include <libtorrent/session.hpp>
#include <libtorrent/torrent_info.hpp>
#include <libtorrent/lazy_entry.hpp>
+#include <libtorrent/magnet_uri.hpp>
#include <boost/filesystem/operations.hpp>
int main(int argc, char* argv[])
@@ -20,7 +21,7 @@ int main(int argc, char* argv[])
if (argc != 2)
{
- std::cerr << "usage: ./simple_client torrent-file\n"
+ std::cerr << "usage: ./sc magnet_uri\n"
"to stop the client, press return.\n";
return 1;
}
@@ -36,10 +37,25 @@ if (argc != 2)
p.ti = new torrent_info(argv[1]);
s.add_torrent(p);
+ bool cont = true;
+ while( cont ) {
// wait for the user to end
- char a;
- std::cin.unsetf(std::ios_base::skipws);
- std::cin >> a;
+ session_status ss = s.status();
+ std::cout << "Session Stats:" << "\n";
+ std::cout << "\t Total Download:" << ss.total_download << " Total Upload:" << ss.total_upload << "\n";
+
+ std::vector<torrent_handle> v = s.get_torrents();
+ for(std::vector<int>::size_type i = 0; i != v.size(); i++) {
+ torrent_handle t = v[i];
+ std::cout << "Torrent " << t.name() << " Progress " << t.status().progress * 100 << "%" << "\n";
+
+ if( t.status().progress == 1.0 ) {
+ exit(0);
+
+ }
+ }
+ sleep( 1 );
+ }
}
#ifndef BOOST_NO_EXCEPTIONS
catch (std::exception& e)

0 comments on commit 820ecfa

Please sign in to comment.