-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransfer.h
More file actions
34 lines (29 loc) · 1.04 KB
/
Copy pathtransfer.h
File metadata and controls
34 lines (29 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef TRANSFER_H
#define TRANSFER_H
#include "buffer.h"
#include "socket.h"
#include "functional"
enum class TransferType {Recieve, Send, None};
using TransferFunction = std::function<OperationResult(Buffer&, size_t)>;
using ConfirmCondition = std::function<bool(Buffer&)>;
class Transfer
{
TransferType type = TransferType::None;
bool transferFinished = true;
bool confirmed = true;
size_t transferSize;
TransferFunction recieve, send;
ConfirmCondition confirmCondition;
OperationResult confirm();
public:
Transfer();
Transfer(const TransferFunction& recieve, const TransferFunction& send);
~Transfer();
void setRecieveFunction(const TransferFunction& recieve);
void setSendFunction(const TransferFunction& send);
OperationResult Start(TransferType type, size_t size, bool needsConfirmation = false);
OperationResult Start(TransferType type, size_t size, const ConfirmCondition& condition);
OperationResult Execute(Buffer& buff);
void End(bool resetClient = false);
};
#endif // TRANSFER_H