Client Events
client.on('ready', callback)
Emitted when the client is ready to accept torrents.
client.on('listening', callback)
Emitted when the client starts listening on a port.
client.on('add', callback)
Emitted when a torrent is added to client.torrents. This fires before the torrent has metadata.
The torrent that was added
client.on('torrent', callback)
Emitted when a torrent is ready to be used (metadata is available and store is ready).
The torrent that is ready
client.on('remove', callback)
Emitted when a torrent is removed from client.torrents.
The torrent that was removed
client.on('seed', callback)
Emitted when a seeded torrent is ready.
The torrent that is seeding
client.on('error', callback)
Emitted when the client encounters a fatal error. The client is automatically destroyed when this occurs.
The error that occurred
Always listen for the ‘error’ event to prevent uncaught exceptions.
client.on('download', callback)
Emitted whenever data is downloaded by any torrent.
Number of bytes downloaded
client.on('upload', callback)
Emitted whenever data is uploaded by any torrent.
Number of bytes uploaded
Torrent Events
torrent.on('infoHash', callback)
Emitted when the info hash of the torrent has been determined.
torrent.on('metadata', callback)
Emitted when the metadata of the torrent has been determined. This includes the full contents of the .torrent file.
torrent.on('ready', callback)
Emitted when the torrent is ready to be used (metadata is available and store is ready).
torrent.on('done', callback)
Emitted when all torrent files have been downloaded.
torrent.on('download', callback)
Emitted whenever data is downloaded.
Number of bytes downloaded
torrent.on('upload', callback)
Emitted whenever data is uploaded.
Number of bytes uploaded
torrent.on('wire', callback)
Emitted whenever a new peer is connected.
The wire (peer connection) instance
The peer’s address (optional)
torrent.on('noPeers', callback)
Emitted when no peers have been found. Emitted separately for each announce type.
One of:
'tracker', 'dht', 'lsd', or 'ut_pex'torrent.on('peer', callback)
Emitted when a peer is added to the torrent swarm.
Peer address or identifier
torrent.on('verified', callback)
Emitted every time a piece is verified.
Index of the verified piece
torrent.on('idle', callback)
Emitted when the torrent has no more active selections and starts idling or seeding.
torrent.on('interested', callback)
Emitted when the client becomes interested in downloading from peers.
torrent.on('uninterested', callback)
Emitted when the client is no longer interested in downloading from peers.
torrent.on('trackerAnnounce', callback)
Emitted when the torrent announces to a tracker.
torrent.on('dhtAnnounce', callback)
Emitted when the torrent announces to the DHT.
torrent.on('warning', callback)
Emitted when there is a warning (non-fatal error).
The warning error
torrent.on('error', callback)
Emitted when the torrent encounters a fatal error. The torrent is automatically destroyed when this occurs.
The error that occurred
If there are no ‘error’ handlers on the torrent, the error will be emitted at
client.on('error'). Always listen for errors in both places.torrent.on('close', callback)
Emitted when the torrent has been destroyed.
File Events
file.on('done', callback)
Emitted when the file has been downloaded.
file.on('stream', callback)
Emitted when the HTTP server creates a new read stream for this file.
This is advanced functionality for manipulating streaming data.
file.on('iterator', callback)
Emitted when the HTTP server creates an async iterator for this file.
This is advanced functionality for low-level data manipulation.