BandwidthSocket

interface BandwidthSocket

The callback surface a bandwidth consumer exposes to a BandwidthManager: pure-Kotlin port of libtorrent's bandwidth_socket (aux_/bandwidth_socket.hpp).

In libtorrent the only implementer is peer_connection. The manager is a pure scheduling algorithm and never touches sockets directly; it just calls back through this interface to hand assigned quota to the consumer and to ask whether the consumer is shutting down. Keeping it abstract lets the limiter be tested in isolation and ported without any I/O.

Functions

Link copied to clipboard
abstract fun assignBandwidth(channel: Int, amount: Int)

Hands amount bytes of quota to this consumer on bandwidth channel (upload or download). The manager calls this once the consumer's outstanding request has been fully satisfied or has run out of time-to-live.

Link copied to clipboard
abstract fun isDisconnecting(): Boolean

True if the consumer is disconnecting; its quota will be reclaimed.