porla_sessions
Access sessions and their torrents.
Exports
count(): number
v1.0
Returns the number of loaded sessions in Porla. If a session fails to load for some reason, it will not be included in this count.
default(): PoSessionHandle | nil
v1.0
Returns the default session - i.e the one marked with is_default in the
database. If there is no default session, or if the default session is not
loaded, this function will return nil.
get(id: number): PoSessionHandle | nil
v1.0
Gets a session by its id. If the session is not loaded, this function will return nil.
Example
local sessions = require("porla_sessions")
local some_session = sessions.get(17)
if some_session ~= nil then
print(some_session.name)
end
list(): PoSessionsIterator
v1.0
Returns an iterator to let you loop through all loaded sessions.
Example
local sessions = require("porla_sessions")
for session in sessions.list() do
print(session.name)
end
metrics(): table
v1.0
Returns the available libtorrent session metrics as a table. Each metric has a
field type that is either counter or gauge depending on the metric type.
This can be used in coordination with the session.stats event to get metrics
for a specific session.
Example
local sessions = require("porla_sessions")
local metrics = sessions.metrics()
print(metrics["tracker.num_queued_tracker_announces"].type) -- prints "counter"