public class SessionManager
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
SessionManager.MutableItem |
Constructor and Description |
---|
SessionManager() |
SessionManager(boolean logging) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(AlertListener listener) |
void |
applySettings(SettingsPack sp) |
void |
dhtAnnounce(Sha1Hash sha1) |
void |
dhtAnnounce(Sha1Hash sha1,
int port,
int flags) |
SessionManager.MutableItem |
dhtGetItem(byte[] key,
byte[] salt,
int timeout) |
Entry |
dhtGetItem(Sha1Hash sha1,
int timeout) |
java.util.ArrayList<TcpEndpoint> |
dhtGetPeers(Sha1Hash sha1,
int timeout) |
long |
dhtNodes() |
void |
dhtPutItem(byte[] publicKey,
byte[] privateKey,
Entry entry,
byte[] salt) |
Sha1Hash |
dhtPutItem(Entry entry) |
void |
download(java.lang.String magnetUri,
java.io.File saveDir)
Downloads a magnet uri.
|
void |
download(TorrentInfo ti,
java.io.File saveDir) |
void |
download(TorrentInfo ti,
java.io.File saveDir,
java.io.File resumeFile,
Priority[] priorities,
java.util.List<TcpEndpoint> peers) |
long |
downloadRate() |
int |
downloadRateLimit() |
void |
downloadRateLimit(int limit) |
java.lang.String |
externalAddress() |
byte[] |
fetchMagnet(java.lang.String uri,
int timeout)
Similar to call
fetchMagnet(String, int, boolean) with
a maximum extra = false . |
byte[] |
fetchMagnet(java.lang.String uri,
int timeout,
boolean extra)
Similar to call
fetchMagnet(String, int, boolean, int) with
a maximum size of 2MB. |
byte[] |
fetchMagnet(java.lang.String uri,
int timeout,
boolean extra,
int maxSize) |
protected void |
finalize() |
TorrentHandle |
find(Sha1Hash sha1) |
boolean |
isDhtRunning() |
boolean |
isFirewalled() |
boolean |
isPaused() |
boolean |
isRunning() |
java.lang.Throwable |
lastAlertError()
This methods return the last error recorded calling the alert
listeners.
|
java.util.List<java.lang.String> |
listenEndpoints() |
java.lang.String |
listenInterfaces() |
void |
listenInterfaces(java.lang.String value) |
void |
loadState(byte[] data) |
java.lang.String |
magnetPeers() |
int |
maxActiveDownloads() |
void |
maxActiveDownloads(int limit) |
int |
maxActiveSeeds() |
void |
maxActiveSeeds(int limit) |
int |
maxConnections() |
void |
maxConnections(int limit) |
int |
maxPeers() |
void |
maxPeers(int limit) |
void |
moveStorage(java.io.File dir) |
protected void |
onAfterStart() |
protected void |
onAfterStop() |
protected void |
onApplySettings(SettingsPack sp) |
protected void |
onBeforeStart() |
protected void |
onBeforeStop() |
void |
pause() |
void |
postDhtStats()
This will cause a
DhtStatsAlert to be posted. |
void |
postSessionStats()
This function will post a
SessionStatsAlert object, containing a
snapshot of the performance counters from the internals of libtorrent. |
void |
postTorrentUpdates()
This functions instructs the session to post the
StateUpdateAlert ,
containing the status of all torrents whose state changed since the
last time this function was called. |
void |
remove(TorrentHandle th) |
void |
remove(TorrentHandle th,
remove_flags_t options) |
void |
removeListener(AlertListener listener) |
void |
reopenNetworkSockets()
Instructs the session to reopen all listen and outgoing sockets.
|
void |
restart()
This method blocks for at least a second plus the time
needed to destroy the native session, don't call it from the UI thread.
|
void |
resume() |
byte[] |
saveState() |
SettingsPack |
settings()
Returns a setting pack with all the settings
the current session is working with.
|
void |
start() |
void |
start(SessionParams params) |
void |
startDht() |
SessionStats |
stats() |
void |
stop()
This method blocks during the destruction of the native session, it
could take some time, don't call this from the UI thread or other
sensitive multithreaded code.
|
void |
stopDht() |
session |
swig() |
long |
totalDownload() |
long |
totalUpload() |
long |
uploadRate() |
int |
uploadRateLimit() |
void |
uploadRateLimit(int limit) |
public SessionManager(boolean logging)
public SessionManager()
public session swig()
public void addListener(AlertListener listener)
public void removeListener(AlertListener listener)
public void start(SessionParams params)
public void start()
public void stop()
public void restart()
public boolean isRunning()
public void pause()
public void resume()
public boolean isPaused()
public SessionStats stats()
public long downloadRate()
public long uploadRate()
public long totalDownload()
public long totalUpload()
public long dhtNodes()
public boolean isFirewalled()
public java.lang.String externalAddress()
public java.util.List<java.lang.String> listenEndpoints()
public SettingsPack settings()
If the current internal session is null, returns null.
public void applySettings(SettingsPack sp)
public int downloadRateLimit()
public void downloadRateLimit(int limit)
public int uploadRateLimit()
public void uploadRateLimit(int limit)
public int maxActiveDownloads()
public void maxActiveDownloads(int limit)
public int maxActiveSeeds()
public void maxActiveSeeds(int limit)
public int maxConnections()
public void maxConnections(int limit)
public int maxPeers()
public void maxPeers(int limit)
public java.lang.String listenInterfaces()
public void listenInterfaces(java.lang.String value)
public void postSessionStats()
SessionStatsAlert
object, containing a
snapshot of the performance counters from the internals of libtorrent.public void postDhtStats()
DhtStatsAlert
to be posted.public void postTorrentUpdates()
StateUpdateAlert
,
containing the status of all torrents whose state changed since the
last time this function was called.
Only torrents who has the state subscription flag set will be included.
public boolean isDhtRunning()
public void startDht()
public void stopDht()
public TorrentHandle find(Sha1Hash sha1)
public void download(TorrentInfo ti, java.io.File saveDir, java.io.File resumeFile, Priority[] priorities, java.util.List<TcpEndpoint> peers)
ti
- the torrent info to downloadsaveDir
- the path to save the downloaded filesresumeFile
- the file with the resume filepriorities
- the initial file prioritiespublic void download(java.lang.String magnetUri, java.io.File saveDir)
magnetUri
- the magnet uri to downloadsaveDir
- the path to save the downloaded filespublic void download(TorrentInfo ti, java.io.File saveDir)
ti
- saveDir
- public void remove(TorrentHandle th, remove_flags_t options)
public void remove(TorrentHandle th)
public byte[] fetchMagnet(java.lang.String uri, int timeout, boolean extra, int maxSize)
uri
- magnet uritimeout
- in secondsmaxSize
- in bytesextra
- if extra data is includedpublic byte[] fetchMagnet(java.lang.String uri, int timeout, boolean extra)
fetchMagnet(String, int, boolean, int)
with
a maximum size of 2MB.uri
- magnet uritimeout
- in secondsextra
- if extra data is includedpublic byte[] fetchMagnet(java.lang.String uri, int timeout)
fetchMagnet(String, int, boolean)
with
a maximum extra = false
.uri
- timeout
- public Entry dhtGetItem(Sha1Hash sha1, int timeout)
sha1
- timeout
- in secondspublic Sha1Hash dhtPutItem(Entry entry)
entry
- the datapublic SessionManager.MutableItem dhtGetItem(byte[] key, byte[] salt, int timeout)
public void dhtPutItem(byte[] publicKey, byte[] privateKey, Entry entry, byte[] salt)
public java.util.ArrayList<TcpEndpoint> dhtGetPeers(Sha1Hash sha1, int timeout)
sha1
- timeout
- in secondspublic void dhtAnnounce(Sha1Hash sha1, int port, int flags)
public void dhtAnnounce(Sha1Hash sha1)
public void moveStorage(java.io.File dir)
dir
- public byte[] saveState()
public void loadState(byte[] data)
public void reopenNetworkSockets()
It's useful in the case your platform doesn't support the built in IP notifier mechanism, or if you have a better more reliable way to detect changes in the IP routing table.
public java.lang.String magnetPeers()
public java.lang.Throwable lastAlertError()
protected void onBeforeStart()
protected void onAfterStart()
protected void onBeforeStop()
protected void onAfterStop()
protected void onApplySettings(SettingsPack sp)
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable