J7mbo / TorrentPHP

Provides a simple-to-use object oriented interface for interacting with torrent clients.
Other
41 stars 16 forks source link

Start all torrents, stop all torrents #6

Open ghost opened 7 years ago

ghost commented 7 years ago

Hi,

I'm wondering if your stop/start method is managing object array? If not, which is the best way to achieve a stop all / pause all?

Thanks!

use TorrentPHP\Client\Deluge\ConnectionConfig,
    TorrentPHP\Client\Deluge\AsyncClientTransport,
    TorrentPHP\Client\Deluge\AsyncClientFactory,
    Alert\ReactorFactory;

$clientFactory = new TorrentPHP\Client\AsyncClientFactory;
$request = new Artax\Request;
$config = new ConnectionConfig([
    'host'     => 'localhost',
    'port'     => 8112,
    'password' => 'deluge'
]);

$transport = new AsyncClientTransport($clientFactory, $request, $config);

$pauseAll= function($response) {
    $adapter->pauseTorrent($response);
};

$transport->getTorrents([], $pauseAll);