Class SessionManager
java.lang.Object
com.frostwire.jlibtorrent.SessionManager
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(AlertListener listener) voidvoiddhtAnnounce(Sha1Hash sha1) voiddhtAnnounce(Sha1Hash sha1, int port, int flags) dhtGetItem(byte[] key, byte[] salt, int timeout) dhtGetItem(Sha1Hash sha1, int timeout) dhtGetPeers(Sha1Hash sha1, int timeout) longdhtNodes()voiddhtPutItem(byte[] publicKey, byte[] privateKey, Entry entry, byte[] salt) dhtPutItem(Entry entry) voiddownload(TorrentInfo ti, File saveDir) voiddownload(TorrentInfo ti, File saveDir, File resumeFile, Priority[] priorities, List<TcpEndpoint> peers, torrent_flags_t flags) voiddownload(String magnetUri, File saveDir, torrent_flags_t flags) Downloads a magnet uri.longintvoiddownloadRateLimit(int limit) byte[]fetchMagnet(String uri, int timeout, File tempDir) find(Sha256Hash sha256) find(TorrentInfo torrentInfo) booleanbooleanbooleanisPaused()booleanThis methods return the last error recorded calling the alert listeners.voidlistenInterfaces(String value) intvoidmaxActiveDownloads(int limit) intvoidmaxActiveSeeds(int limit) intvoidmaxConnections(int limit) intmaxPeers()voidmaxPeers(int limit) voidmoveStorage(File dir) protected voidprotected voidprotected voidprotected voidprotected voidvoidpause()voidThis will cause aDhtStatsAlertto be posted.voidThis function will post aSessionStatsAlertobject, containing a snapshot of the performance counters from the internals of libtorrent.voidThis functions instructs the session to post theStateUpdateAlert, containing the status of all torrents whose state changed since the last time this function was called.voidremove(TorrentHandle th) voidremove(TorrentHandle th, remove_flags_t options) voidremoveListener(AlertListener listener) voidInstructs the session to reopen all listen and outgoing sockets.voidrestart()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.voidresume()byte[]settings()Returns a setting pack with all the settings the current session is working with.voidstart()voidstart(SessionParams params) voidstartDht()stats()voidstop()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.voidstopDht()swig()longlonglongintvoiduploadRateLimit(int limit)
-
Constructor Details
-
SessionManager
public SessionManager(boolean logging) -
SessionManager
public SessionManager()
-
-
Method Details
-
swig
-
addListener
-
removeListener
-
start
-
start
public void start() -
stop
public 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. -
restart
public 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. -
isRunning
public boolean isRunning() -
pause
public void pause() -
resume
public void resume() -
isPaused
public boolean isPaused() -
stats
-
downloadRate
public long downloadRate() -
uploadRate
public long uploadRate() -
totalDownload
public long totalDownload() -
totalUpload
public long totalUpload() -
dhtNodes
public long dhtNodes() -
isFirewalled
public boolean isFirewalled() -
externalAddress
-
listenEndpoints
-
settings
Returns a setting pack with all the settings the current session is working with.If the current internal session is null, returns null.
- Returns:
-
applySettings
-
downloadRateLimit
public int downloadRateLimit() -
downloadRateLimit
public void downloadRateLimit(int limit) -
uploadRateLimit
public int uploadRateLimit() -
uploadRateLimit
public void uploadRateLimit(int limit) -
maxActiveDownloads
public int maxActiveDownloads() -
maxActiveDownloads
public void maxActiveDownloads(int limit) -
maxActiveSeeds
public int maxActiveSeeds() -
maxActiveSeeds
public void maxActiveSeeds(int limit) -
maxConnections
public int maxConnections() -
maxConnections
public void maxConnections(int limit) -
maxPeers
public int maxPeers() -
maxPeers
public void maxPeers(int limit) -
listenInterfaces
-
listenInterfaces
-
postSessionStats
public void postSessionStats()This function will post aSessionStatsAlertobject, containing a snapshot of the performance counters from the internals of libtorrent. -
postDhtStats
public void postDhtStats()This will cause aDhtStatsAlertto be posted. -
postTorrentUpdates
public void postTorrentUpdates()This functions instructs the session to post theStateUpdateAlert, 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.
-
isDhtRunning
public boolean isDhtRunning() -
startDht
public void startDht() -
stopDht
public void stopDht() -
find
-
find
-
find
-
download
public void download(TorrentInfo ti, File saveDir, File resumeFile, Priority[] priorities, List<TcpEndpoint> peers, torrent_flags_t flags) - Parameters:
ti- the torrent info to downloadsaveDir- the path to save the downloaded filesresumeFile- the file with the resume filepriorities- the initial file priorities
-
download
Downloads a magnet uri.- Parameters:
magnetUri- the magnet uri to downloadsaveDir- the path to save the downloaded files
-
download
- Parameters:
ti-saveDir-
-
remove
-
remove
-
fetchMagnet
-
dhtGetItem
-
dhtPutItem
-
dhtGetItem
-
dhtPutItem
-
dhtGetPeers
- Parameters:
sha1-timeout- in seconds- Returns:
- the peer list or an empty list
-
dhtAnnounce
-
dhtAnnounce
-
moveStorage
- Parameters:
dir-
-
saveState
public byte[] saveState() -
reopenNetworkSockets
public void reopenNetworkSockets()Instructs the session to reopen all listen and outgoing sockets.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.
-
magnetPeers
-
lastAlertError
This methods return the last error recorded calling the alert listeners.- Returns:
- the last alert listener exception registered (or null)
-
onBeforeStart
protected void onBeforeStart() -
onAfterStart
protected void onAfterStart() -
onBeforeStop
protected void onBeforeStop() -
onAfterStop
protected void onAfterStop() -
onApplySettings
-