forked from premiere/premiere-libtorrent
add extension hook on sending payload
This commit is contained in:
parent
1045e385de
commit
4ddedc6a21
|
@ -181,7 +181,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/socket.hpp"
|
||||
#include "libtorrent/sha1_hash.hpp" // for sha1_hash
|
||||
#include "libtorrent/error_code.hpp"
|
||||
#include "libtorrent/torrent_peer.hpp" // for torrent_peer
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
|
@ -198,8 +197,8 @@ namespace libtorrent
|
|||
class alert;
|
||||
struct torrent_plugin;
|
||||
class torrent;
|
||||
struct add_torrent_params;
|
||||
struct torrent_peer;
|
||||
struct add_torrent_params;
|
||||
|
||||
// this is the base class for a session plugin. One primary feature
|
||||
// is that it is notified of all torrents that are added to the session,
|
||||
|
@ -415,6 +414,10 @@ namespace libtorrent
|
|||
// called after a choke message has been sent to the peer
|
||||
virtual void sent_unchoke() {}
|
||||
|
||||
// called after piece data has been sent to the peer
|
||||
// this can be used for stats book keeping
|
||||
virtual void sent_payload(int /* bytes */) {}
|
||||
|
||||
// called when libtorrent think this peer should be disconnected.
|
||||
// if the plugin returns false, the peer will not be disconnected.
|
||||
virtual bool can_disconnect(error_code const& /*ec*/) { return true; }
|
||||
|
|
|
@ -1148,6 +1148,16 @@ namespace libtorrent
|
|||
void peer_connection::sent_bytes(int bytes_payload, int bytes_protocol)
|
||||
{
|
||||
m_statistics.sent_bytes(bytes_payload, bytes_protocol);
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
if (bytes_payload)
|
||||
{
|
||||
for (extension_list_t::iterator i = m_extensions.begin()
|
||||
, end(m_extensions.end()); i != end; ++i)
|
||||
{
|
||||
(*i)->sent_payload(bytes_payload);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (m_ignore_stats) return;
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
if (!t) return;
|
||||
|
|
Loading…
Reference in New Issue