Class SessionManager

java.lang.Object
com.frostwire.jlibtorrent.SessionManager

public class SessionManager extends Object
  • Constructor Details

    • SessionManager

      public SessionManager(boolean logging)
    • SessionManager

      public SessionManager()
  • Method Details

    • swig

      public session swig()
    • addListener

      public void addListener(AlertListener listener)
    • removeListener

      public void removeListener(AlertListener listener)
    • start

      public void start(SessionParams params)
    • 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

      public SessionStats 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

      public String externalAddress()
    • listenEndpoints

      public List<String> listenEndpoints()
    • settings

      public SettingsPack 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

      public void applySettings(SettingsPack sp)
    • 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

      public String listenInterfaces()
    • listenInterfaces

      public void listenInterfaces(String value)
    • postSessionStats

      public void postSessionStats()
      This function will post a SessionStatsAlert object, containing a snapshot of the performance counters from the internals of libtorrent.
    • postDhtStats

      public void postDhtStats()
      This will cause a DhtStatsAlert to be posted.
    • postTorrentUpdates

      public 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.

      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

      public TorrentHandle find(Sha1Hash sha1)
    • find

      public TorrentHandle find(Sha256Hash sha256)
    • find

      public TorrentHandle find(TorrentInfo torrentInfo)
    • 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 download
      saveDir - the path to save the downloaded files
      resumeFile - the file with the resume file
      priorities - the initial file priorities
    • download

      public void download(String magnetUri, File saveDir, torrent_flags_t flags)
      Downloads a magnet uri.
      Parameters:
      magnetUri - the magnet uri to download
      saveDir - the path to save the downloaded files
    • download

      public void download(TorrentInfo ti, File saveDir)
      Parameters:
      ti -
      saveDir -
    • remove

      public void remove(TorrentHandle th, remove_flags_t options)
    • remove

      public void remove(TorrentHandle th)
    • fetchMagnet

      public byte[] fetchMagnet(String uri, int timeout, File tempDir)
      Parameters:
      uri - magnet uri
      timeout - in seconds
      Returns:
      the bencoded info or null
    • dhtGetItem

      public Entry dhtGetItem(Sha1Hash sha1, int timeout)
      Parameters:
      sha1 -
      timeout - in seconds
      Returns:
      the item
    • dhtPutItem

      public Sha1Hash dhtPutItem(Entry entry)
      Parameters:
      entry - the data
      Returns:
      the target key
    • dhtGetItem

      public SessionManager.MutableItem dhtGetItem(byte[] key, byte[] salt, int timeout)
    • dhtPutItem

      public void dhtPutItem(byte[] publicKey, byte[] privateKey, Entry entry, byte[] salt)
    • dhtGetPeers

      public ArrayList<TcpEndpoint> dhtGetPeers(Sha1Hash sha1, int timeout)
      Parameters:
      sha1 -
      timeout - in seconds
      Returns:
      the peer list or an empty list
    • dhtAnnounce

      public void dhtAnnounce(Sha1Hash sha1, int port, int flags)
    • dhtAnnounce

      public void dhtAnnounce(Sha1Hash sha1)
    • moveStorage

      public void moveStorage(File dir)
      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

      public String magnetPeers()
    • lastAlertError

      public Throwable 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

      protected void onApplySettings(SettingsPack sp)