10#ifndef SNBMODULES_INCLUDE_SNBMODULES_TRANSFER_SESSION_HPP_
11#define SNBMODULES_INCLUDE_SNBMODULES_TRANSFER_SESSION_HPP_
87 std::filesystem::path work_dir,
88 std::vector<std::string> bk_conn = std::vector<std::string>(),
89 std::set<std::string> client_conn = std::set<std::string>());
105 const std::map<e_session_type, std::string> MyEnumStrings{ {
Downloader,
"Downloader" }, {
Uploader,
"Uploader" } };
106 auto it = MyEnumStrings.find(e);
107 return it == MyEnumStrings.end() ?
"Not supported" : it->second;
114 void add_file(std::shared_ptr<TransferMetadata> fmeta)
TransferSession class contained in a client, is a wrapper for a transfer. extend notification interfa...
GroupMetadata & get_transfer_options()
bool resume_file(TransferMetadata &f_meta, bool is_multiple=false)
void set_target_clients(std::set< std::string > clients)
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)
bool operator==(TransferSession const &other) const
equal operator, used to compare sessions in a set (client)
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 operator<(TransferSession const &other) const
Operator <, used to compare sessions in a set (client)
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.
std::string m_session_id
Unique identifier of the session, used to identify the session in the client and to target notificati...
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::set< std::string > m_target_clients
clients that dowload the files, only used by uploader
void add_file(std::shared_ptr< TransferMetadata > fmeta)
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 ...
TransferSession & operator=(TransferSession &&)=default
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.
NotificationData class, represent a notification.
e_notification_type
Different type of notifications possible to send.