Package org.johnnei.javatorrent
Class TorrentClient.Builder
- java.lang.Object
-
- org.johnnei.javatorrent.TorrentClient.Builder
-
- Enclosing class:
- TorrentClient
public static class TorrentClient.Builder extends Object
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
-
-
-
Method Detail
-
registerModule
public TorrentClient.Builder registerModule(IModule module)
-
enableExtensionBit
public TorrentClient.Builder enableExtensionBit(int bit)
Enables a bit in the extension bytes. According to BEP 3 there are 8 extension bytes (reserved bytes). The bit numbers are represented in the following order: Right to left, starting at zero. For reference see BEP 10 which indicates that bit 20 must be enabled.- Parameters:
bit- The bit to enable.
-
acceptIncomingConnections
public TorrentClient.Builder acceptIncomingConnections(boolean acceptIncomingConnections)
Enables (or disables) the starting of the peer connection accepts upon building of the torrent client. By default this is disabled.- Parameters:
acceptIncomingConnections-truewhen connections should be accepted.- Returns:
- this
-
registerMessage
public TorrentClient.Builder registerMessage(int id, Supplier<IMessage> messageSupplier)
-
registerTrackerProtocol
public TorrentClient.Builder registerTrackerProtocol(String protocol, CheckedBiFunction<String,TorrentClient,ITracker,TrackerException> supplier)
-
setPhaseRegulator
public TorrentClient.Builder setPhaseRegulator(PhaseRegulator phaseRegulator)
-
setConnectionDegradation
public TorrentClient.Builder setConnectionDegradation(ConnectionDegradation connectionDegradation)
-
setPeerConnector
public TorrentClient.Builder setPeerConnector(Function<TorrentClient,IPeerConnector> peerConnector)
-
setExecutorService
public TorrentClient.Builder setExecutorService(ScheduledExecutorService executorService)
-
setRequestLimiter
public TorrentClient.Builder setRequestLimiter(IRequestLimiter requestLimiter)
-
setDownloadPort
public TorrentClient.Builder setDownloadPort(int downloadPort)
Sets the download port at which we are listening- Parameters:
downloadPort- The port at which we are listening- Returns:
- The modified instance
-
setPeerDistributor
public TorrentClient.Builder setPeerDistributor(Function<TorrentClient,IPeerDistributor> peerDistributor)
Sets the peer distributor which is being used by theIPeerConnectorimplementation.- Parameters:
peerDistributor- The peer distributor.
-
build
public TorrentClient build() throws Exception
- Throws:
Exception
-
-