forked from premiere/premiere-libtorrent
Add session_stats_alert to python bindings
This commit is contained in:
parent
6552138ae5
commit
2e90ea7493
|
@ -6,6 +6,8 @@
|
|||
#include <libtorrent/alert.hpp>
|
||||
#include <libtorrent/alert_types.hpp>
|
||||
#include <libtorrent/piece_picker.hpp> // for piece_block
|
||||
#include <libtorrent/performance_counters.hpp>
|
||||
#include <libtorrent/session_stats.hpp>
|
||||
#include <memory>
|
||||
|
||||
using namespace boost::python;
|
||||
|
@ -179,6 +181,19 @@ dict dht_put_item(dht_put_alert const& alert)
|
|||
return d;
|
||||
}
|
||||
|
||||
dict session_stats_values(session_stats_alert const& alert)
|
||||
{
|
||||
std::vector<stats_metric> map = session_stats_metrics();
|
||||
dict d;
|
||||
|
||||
for (std::vector<stats_metric>::const_iterator i = map.begin();
|
||||
i != map.end(); ++i)
|
||||
{
|
||||
d[i->name] = alert.values[i->value_index];
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
void bind_alert()
|
||||
{
|
||||
using boost::noncopyable;
|
||||
|
@ -725,4 +740,8 @@ void bind_alert()
|
|||
"dht_put_alert", no_init)
|
||||
.add_property("item", &dht_put_item)
|
||||
;
|
||||
class_<session_stats_alert, bases<alert>, noncopyable>(
|
||||
"session_stats_alert", no_init)
|
||||
.add_property("values", &session_stats_values)
|
||||
;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue