transfer_receiver.hpp 1.03 KB
Newer Older
louiz’'s avatar
louiz’ committed
1 2 3 4 5 6 7 8 9
/** @addtogroup Network
 *  @{
 */

/**
 * Represent an outgoing file transfer.
 * @class TransferReceiver
 */

10 11
#ifndef TRANSFER_RECEIVER_HPP
# define TRANSFER_RECEIVER_HPP
louiz’'s avatar
louiz’ committed
12

13 14
#include <iostream>
#include <string>
15
#include <functional>
16 17
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
18

19
#include <network/message.hpp>
louiz’'s avatar
louiz’ committed
20

21 22 23 24
class TLSSocket;

template <typename SocketType>
class MessageHandler;
louiz’'s avatar
louiz’ committed
25 26 27 28

class TransferReceiver
{
public:
29 30
  TransferReceiver(MessageHandler<TLSSocket>*, const std::string&, const std::string&, int,
                   std::function<void(const TransferReceiver*)>&&);
louiz’'s avatar
louiz’ committed
31
  ~TransferReceiver();
32
  void stop();
louiz’'s avatar
louiz’ committed
33 34 35 36 37

private:
  TransferReceiver(const TransferReceiver&);
  TransferReceiver& operator=(const TransferReceiver&);

38
  void get_next_chunk(Message*);
39 40

  MessageHandler<TLSSocket>* client;
louiz’'s avatar
louiz’ committed
41
  std::string id;
42
  boost::filesystem::path filename;
louiz’'s avatar
louiz’ committed
43 44
  int length;
  int received_length;
45 46
  std::function<void(const TransferReceiver*)> end_callback;
  boost::filesystem::ofstream file;
louiz’'s avatar
louiz’ committed
47 48
};

49
#endif // TRANSFER_RECEIVER_HPP
louiz’'s avatar
louiz’ committed
50 51

/**@}*/