forked from premiere/premiere-libtorrent
*** empty log message ***
This commit is contained in:
parent
adbfc0378c
commit
7645360cf9
|
@ -230,6 +230,8 @@ The ``session`` class has the following synopsis::
|
|||
void set_upload_rate_limit(int bytes_per_second);
|
||||
void set_download_rate_limit(int bytes_per_second);
|
||||
|
||||
session_status status() const;
|
||||
|
||||
bool is_listening() const;
|
||||
unsigned short listen_port() const;
|
||||
bool listen_on(
|
||||
|
@ -328,6 +330,50 @@ you don't want to limit upload rate, you can set this to -1 (the default).
|
|||
of upload rate.
|
||||
|
||||
|
||||
status()
|
||||
--------
|
||||
|
||||
::
|
||||
|
||||
session_status status() const;
|
||||
|
||||
``status()`` returns session wide statistics and status. The ``session_status``
|
||||
struct has the following members::
|
||||
|
||||
struct session_status
|
||||
{
|
||||
bool has_incoming_connections;
|
||||
|
||||
float upload_rate;
|
||||
float download_rate;
|
||||
|
||||
float payload_upload_rate;
|
||||
float payload_download_rate;
|
||||
|
||||
size_type total_download;
|
||||
size_type total_upload;
|
||||
|
||||
size_type total_payload_download;
|
||||
size_type total_payload_upload;
|
||||
|
||||
int num_peers;
|
||||
};
|
||||
|
||||
``has_incoming_connections`` is false as long as no incoming connections has been
|
||||
established on the listening socket. Every time you change the listen port, this will
|
||||
be reset to false.
|
||||
|
||||
``upload_rate``, ``download_rate``, ``payload_download_rate`` and ``payload_upload_rate``
|
||||
are the total download and upload rates accumulated from all torrents. The payload
|
||||
versions is the payload download only.
|
||||
|
||||
``total_download`` and ``total_upload`` are the total number of bytes downloaded and
|
||||
uploaded to and from all torrents. ``total_payload_download`` and ``total_payload_upload``
|
||||
are the same thing but where only the payload is considered.
|
||||
|
||||
``num_peers`` is the total number of peer connections this session have.
|
||||
|
||||
|
||||
is_listening() listen_port() listen_on()
|
||||
----------------------------------------
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ namespace libtorrent
|
|||
// caclulate the upload/download and number
|
||||
// of connections this torrent needs. And prepare
|
||||
// it for being used by allocate_resources.
|
||||
void second_tick();
|
||||
void second_tick(stat& accumulator);
|
||||
|
||||
// debug purpose only
|
||||
void print(std::ostream& os) const;
|
||||
|
|
|
@ -636,10 +636,7 @@ namespace libtorrent { namespace detail
|
|||
}
|
||||
|
||||
// tick() will set the used upload quota
|
||||
i->second->second_tick();
|
||||
|
||||
// accumulate the statistics from all torrents
|
||||
m_stat += i->second->statistics();
|
||||
i->second->second_tick(m_stat);
|
||||
++i;
|
||||
}
|
||||
purge_connections();
|
||||
|
@ -898,6 +895,8 @@ namespace libtorrent
|
|||
m_impl.m_listen_socket.reset();
|
||||
}
|
||||
|
||||
m_impl.m_incoming_connection = false;
|
||||
|
||||
m_impl.m_listen_port_range = port_range;
|
||||
m_impl.m_listen_interface = address(net_interface, port_range.first);
|
||||
m_impl.open_listen_port();
|
||||
|
@ -913,7 +912,24 @@ namespace libtorrent
|
|||
session_status session::status() const
|
||||
{
|
||||
session_status s;
|
||||
// TODO: implement
|
||||
s.has_incoming_connections = m_impl.m_incoming_connection;
|
||||
s.num_peers = (int)m_impl.m_connections.size();
|
||||
|
||||
s.download_rate = m_impl.m_stat.download_rate();
|
||||
s.upload_rate = m_impl.m_stat.upload_rate();
|
||||
|
||||
s.payload_download_rate = m_impl.m_stat.download_payload_rate();
|
||||
s.payload_upload_rate = m_impl.m_stat.upload_payload_rate();
|
||||
|
||||
s.total_download = m_impl.m_stat.total_protocol_download()
|
||||
+ m_impl.m_stat.total_payload_download();
|
||||
|
||||
s.total_upload = m_impl.m_stat.total_protocol_upload()
|
||||
+ m_impl.m_stat.total_payload_upload();
|
||||
|
||||
s.total_payload_download = m_impl.m_stat.total_payload_download();
|
||||
s.total_payload_upload = m_impl.m_stat.total_payload_upload();
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
|
@ -647,7 +647,7 @@ namespace libtorrent
|
|||
m_time_scaler = 0;
|
||||
}
|
||||
|
||||
void torrent::second_tick()
|
||||
void torrent::second_tick(stat& accumulator)
|
||||
{
|
||||
if (m_paused) return;
|
||||
|
||||
|
@ -672,7 +672,6 @@ namespace libtorrent
|
|||
{
|
||||
peer_connection* p = i->second;
|
||||
m_stat += p->statistics();
|
||||
|
||||
// updates the peer connection's ul/dl bandwidth
|
||||
// resource requests
|
||||
p->second_tick();
|
||||
|
@ -698,6 +697,7 @@ namespace libtorrent
|
|||
m_dl_bandwidth_quota.max
|
||||
= std::min(m_dl_bandwidth_quota.max, m_download_bandwidth_limit);
|
||||
|
||||
accumulator += m_stat;
|
||||
m_stat.second_tick();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue