class PiecePicker;
class CongestionController;
class PeerSelector;
+ typedef void (*ProgressCallback) (int transfer, bin64_t bin);
/** A class representing single file transfer. */
tint init_time_;
+ #define SWFT_MAX_TRANSFER_CB 8
+ ProgressCallback callbacks[SWFT_MAX_TRANSFER_CB];
+ uint8_t cb_agg[SWFT_MAX_TRANSFER_CB];
+ int cb_installed;
+
public:
void OnDataIn (bin64_t pos);
void OnPexIn (const Address& addr);
friend uint64_t SeqComplete (int fdes);
friend int Open (const char* filename, const Sha1Hash& hash) ;
friend void Close (int fd) ;
+ friend void AddProgressCallback (int transfer,ProgressCallback cb,uint8_t agg);
+ friend void RemoveProgressCallback (int transfer,ProgressCallback cb);
+ friend void ExternallyRetrieved (int transfer,bin64_t piece);
};
* @param expires (not used currently) when to consider request expired
* @return the bin number to request */
virtual bin64_t Pick (binmap_t& offered, uint64_t max_width, tint expires) = 0;
+ virtual void LimitRange (bin64_t range) = 0;
virtual ~PiecePicker() {}
};
Normally, API users do not deal with this class. */
class Channel {
public:
- Channel (FileTransfer* file, int socket=-1, Address peer=Address());
+ Channel (FileTransfer* file, int socket=INVALID_SOCKET, Address peer=Address());
~Channel();
typedef enum {
static const char* SEND_CONTROL_MODES[];
- static Channel*
- RecvDatagram (int socket);
+ static void RecvDatagram (SOCKET socket);
static void Loop (tint till);
void Recv (Datagram& dgram);
return i<channels.size()?channels[i]:NULL;
}
static void CloseTransfer (FileTransfer* trans);
- static SOCKET default_socket() { return sockets[0]; }
protected:
/** Channel id: index in the channel array. */
static PeerSelector* peer_selector;
- static SOCKET sockets[8];
- static int socket_count;
static tint last_tick;
static tbheap send_queue;
int Listen (Address addr);
/** Run send/receive loop for the specified amount of time. */
void Loop (tint till);
+ bool Listen3rdPartySocket (sckrwecb_t);
/** Stop listening to a port. */
void Shutdown (int sock_des=-1);
/** Returns the number of bytes that are complete sequentially, starting from the
beginning, till the first not-yet-retrieved packet. */
uint64_t SeqComplete (int fdes);
+ /***/
+ int Find (Sha1Hash hash);
+ void AddProgressCallback (int transfer,ProgressCallback cb,uint8_t agg);
+ void RemoveProgressCallback (int transfer,ProgressCallback cb);
+ void ExternallyRetrieved (int transfer,bin64_t piece);
//uint32_t Width (const tbinvec& v);