18#ifndef NETFILETRANSFER_H
19#define NETFILETRANSFER_H
24#include <unordered_map>
27class CFileTransferResponseMessage;
28class CFileTransferDataMessage;
29class CFileTransferAckMessage;
67 void StartTask(std::function<
void(std::string)> task);
static const size_t MAX_FILE_TRANSFER_SIZE
Definition: NetFileTransfer.h:43
static const size_t DEFAULT_FILE_TRANSFER_PACKET_SIZE
Definition: NetFileTransfer.h:34
static const size_t DEFAULT_FILE_TRANSFER_WINDOW_SIZE
Definition: NetFileTransfer.h:40
static const size_t MiB
Definition: alignment.h:107
Handles transferring files between clients and servers.
Definition: NetFileTransfer.h:49
void Poll()
Call frequently (e.g.
Definition: NetFileTransfer.cpp:171
CNetFileTransferer(INetSession *session)
Definition: NetFileTransfer.h:51
Status OnFileTransferData(const CFileTransferDataMessage &message)
Definition: NetFileTransfer.cpp:72
Status OnFileTransferAck(const CFileTransferAckMessage &message)
Definition: NetFileTransfer.cpp:120
Status HandleMessageReceive(const CNetMessage &message)
Should be called when a message is received from the network.
Definition: NetFileTransfer.cpp:28
void StartResponse(u32 requestID, const std::string &data)
Registers data to be sent in response to a request.
Definition: NetFileTransfer.cpp:155
u32 m_NextRequestID
Definition: NetFileTransfer.h:101
void StartTask(std::function< void(std::string)> task)
Registers a file-receiving task.
Definition: NetFileTransfer.cpp:144
std::map< u32, CNetFileSendTask > FileSendTasksMap
Definition: NetFileTransfer.h:121
INetSession * m_Session
Definition: NetFileTransfer.h:99
FileSendTasksMap m_FileSendTasks
Definition: NetFileTransfer.h:122
Status OnFileTransferResponse(const CFileTransferResponseMessage &message)
Definition: NetFileTransfer.cpp:46
double m_LastProgressReportTime
Definition: NetFileTransfer.h:124
FileReceiveTasksMap m_FileReceiveTasks
Definition: NetFileTransfer.h:119
std::unordered_map< u32, AsyncFileReceiveTask > FileReceiveTasksMap
Definition: NetFileTransfer.h:118
The base class for all network messages exchanged within the game.
Definition: NetMessage.h:33
Interface for sessions to which messages can be sent.
Definition: NetSession.h:56
i64 Status
Error handling system.
Definition: status.h:173
Definition: NetFileTransfer.h:105
std::function< void(std::string)> onComplete
Called when m_Buffer contains the full received data.
Definition: NetFileTransfer.h:109
size_t length
Definition: NetFileTransfer.h:113
std::string buffer
Definition: NetFileTransfer.h:115
Asynchronous file-sending task.
Definition: NetFileTransfer.h:91
size_t offset
Definition: NetFileTransfer.h:94
size_t packetsInFlight
Definition: NetFileTransfer.h:96
size_t maxWindowSize
Definition: NetFileTransfer.h:95
u32 requestID
Definition: NetFileTransfer.h:92
std::string buffer
Definition: NetFileTransfer.h:93
uint32_t u32
Definition: types.h:39