42
42
#include <rak/functional.h>
43
43
#include <rak/unordered_vector.h>
44
44
#include <rak/socket_address.h>
45
#include <torrent/connection_manager.h>
46
47
#include "net/socket_fd.h"
57
58
typedef rak::unordered_vector<Handshake*> base_type;
58
59
typedef uint32_t size_type;
60
typedef rak::mem_fun1<DownloadManager, DownloadMain*, const std::string&> SlotDownloadId;
61
typedef rak::mem_fun1<DownloadManager, DownloadMain*, const char*> SlotDownloadId;
62
63
using base_type::empty;
77
78
void add_incoming(SocketFd fd, const rak::socket_address& sa);
78
79
void add_outgoing(const rak::socket_address& sa, DownloadMain* info);
80
void slot_download_id(SlotDownloadId s) { m_slotDownloadId = s; }
81
void slot_download_id(SlotDownloadId s) { m_slotDownloadId = s; }
82
void slot_download_id_obfuscated(SlotDownloadId s) { m_slotDownloadIdObfuscated = s; }
82
84
void receive_succeeded(Handshake* h);
83
void receive_failed(Handshake* h);
85
void receive_failed(Handshake* h, int message, int error);
86
void receive_timeout(Handshake* h);
85
88
// This needs to be filterable slot.
86
DownloadMain* download_info(const std::string& hash) { return m_slotDownloadId(hash); }
89
DownloadMain* download_info(const char* hash) { return m_slotDownloadId(hash); }
90
DownloadMain* download_info_obfuscated(const char* hash) { return m_slotDownloadIdObfuscated(hash); }
93
void create_outgoing(const rak::socket_address& sa, DownloadMain* info, int encryptionOptions);
89
94
void erase(Handshake* handshake);
91
96
bool setup_socket(SocketFd fd);
93
inline void delete_handshake(Handshake* h);
95
inline void post_insert(Handshake* h, PeerConnectionBase* pcb);
97
98
SlotDownloadId m_slotDownloadId;
99
SlotDownloadId m_slotDownloadIdObfuscated;