25 std::filesystem::path work_dir,
26 std::vector<std::string> bk_conn ,
27 std::set<std::string> client_conn )
30 , m_session_id(
std::move(id))
32 , m_transfer_options(
std::move(transfer_options))
35 m_work_dir(
std::move(work_dir))
37 std::filesystem::create_directories(
m_work_dir);
54 TLOG() <<
"Generating torrent files...";
58 TLOG() <<
"Writing magnet link data into transfer Metadata "
59 <<
get_work_dir().append(f_meta->get_file_name() +
".torrent");
61 lt::torrent_info t(
get_work_dir().append(f_meta->get_file_name() +
".torrent").string(), ec);
67 TLOG() <<
"Magnet link: " << lt::make_magnet_uri(t);
68 f_meta->set_magnet_link(lt::make_magnet_uri(t) +
"&x.pe=" +
get_ip().
get_ip() +
":" +
176 const std::string& data )
360 std::this_thread::sleep_for(std::chrono::seconds(1));
394 std::this_thread::sleep_for(std::chrono::seconds(1));
414 std::this_thread::sleep_for(std::chrono::seconds(1));
bool send_notification(const notification_type::e_notification_type ¬if, const std::string &src, const std::string &dst, const std::string &id_conn, const std::string &data="", int tries=-1)
Send a notification during m_timeout_send ms.
const std::vector< std::string > & get_bookkeepers_conn() const
Init the connection interface, Only used for standalone application.
void generate_torrents_files(const std::filesystem::path &dest, const std::string &tracker)
bool resume_file(TransferMetadata &f_meta, bool is_multiple=false)
bool is_downloader()
Usefull to check if the session is a downloader.
virtual ~TransferSession()
Destructor Kill all threads created by the session (TODO : useless ?)
bool hash_file(TransferMetadata &f_meta, bool is_multiple=false)
bool cancel_file(TransferMetadata &f_meta, bool is_multiple=false)
IPFormat m_ip
Ip of the client TODO : useless ? the session cannot have a unique connection.
bool action_on_receive_notification(NotificationData notif) override
handle actions to be taken when a notification is received. The notification is passed as a parameter...
TransferSession(TransferSession &&)=default
std::string get_session_id() const
GroupMetadata m_transfer_options
A session must contain a transfer matadata. The session is basically a transfer wrapper.
bool upload_file(TransferMetadata &f_meta, bool is_multiple=false)
bool send_notification_to_targets(notification_type::e_notification_type type, const std::string &data="")
Send a notification to every targets of the session, generally for the uploader.
bool download_file(TransferMetadata &f_meta, std::filesystem::path dest, bool is_multiple=false)
std::filesystem::path get_work_dir() const
e_session_type m_type
Type of session, uploader or downloader. Used to block access to some functions.
bool update_metadata_to_bookkeeper(TransferMetadata &f_meta)
std::unique_ptr< TransferInterfaceAbstract > m_transfer_interface
Abstract interface can reference to any protocol used to transfer data.
bool is_uploader()
Usefull to check if the session is a uploader.
const GroupMetadata & get_transfer_options() const
const std::set< std::string > & get_target_clients() const
std::string to_string() const
bool start_file(TransferMetadata &f_meta)
Start the session by downloading or uploading files depending on the type of session TODO : separate ...
static std::string session_type_to_string(e_session_type e)
bool update_metadatas_to_bookkeeper()
bool pause_file(TransferMetadata &f_meta, bool is_multiple=false)
std::filesystem::path m_work_dir
List of threads created by the session TODO : useless ? should be handle in client.
bool download_all(const std::filesystem::path &dest)
e_session_type
Different type of session.
@ Downloader
TransferSession used to download files from uploaders client.
@ Uploader
TransferSession used to upload files to downloaders client.
void warning(const Issue &issue)
void fatal(const Issue &issue)
void error(const Issue &issue)
NotificationData class, represent a notification.
e_notification_type
Different type of notifications possible to send.
static std::string protocols_to_string(e_protocol_type e)
static std::string status_to_string(e_status e)