Patch by Jerry:
- Added fixed pause between raising each file transfer event - Removed redundant member variables in CClient and CServer
This commit is contained in:
parent
811cfd146d
commit
289f1ff71f
|
@ -46,8 +46,6 @@
|
||||||
// CClient
|
// CClient
|
||||||
//
|
//
|
||||||
|
|
||||||
const size_t CClient::m_chunkSize = 1024 * 512; // 512kb
|
|
||||||
|
|
||||||
CClient::CClient(IEventQueue* events,
|
CClient::CClient(IEventQueue* events,
|
||||||
const CString& name, const CNetworkAddress& address,
|
const CString& name, const CNetworkAddress& address,
|
||||||
ISocketFactory* socketFactory,
|
ISocketFactory* socketFactory,
|
||||||
|
|
|
@ -222,7 +222,6 @@ private:
|
||||||
CCryptoOptions m_crypto;
|
CCryptoOptions m_crypto;
|
||||||
std::size_t m_expectedFileSize;
|
std::size_t m_expectedFileSize;
|
||||||
CString m_receivedFileData;
|
CString m_receivedFileData;
|
||||||
static const size_t m_chunkSize;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -48,8 +48,6 @@
|
||||||
// CServer
|
// CServer
|
||||||
//
|
//
|
||||||
|
|
||||||
const size_t CServer::m_chunkSize = 1024 * 512; // 512kb
|
|
||||||
|
|
||||||
CServer::CServer(CConfig& config, CPrimaryClient* primaryClient, CScreen* screen, IEventQueue* events) :
|
CServer::CServer(CConfig& config, CPrimaryClient* primaryClient, CScreen* screen, IEventQueue* events) :
|
||||||
m_events(events),
|
m_events(events),
|
||||||
m_mock(false),
|
m_mock(false),
|
||||||
|
|
|
@ -468,7 +468,6 @@ private:
|
||||||
// file transfer
|
// file transfer
|
||||||
size_t m_expectedFileSize;
|
size_t m_expectedFileSize;
|
||||||
CString m_receivedFileData;
|
CString m_receivedFileData;
|
||||||
static const size_t m_chunkSize;
|
|
||||||
CString m_fileTransferSrc;
|
CString m_fileTransferSrc;
|
||||||
CString m_fileTransferDes;
|
CString m_fileTransferDes;
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,10 +22,13 @@
|
||||||
#include "IEventQueue.h"
|
#include "IEventQueue.h"
|
||||||
#include "CEventTypes.h"
|
#include "CEventTypes.h"
|
||||||
#include "CLog.h"
|
#include "CLog.h"
|
||||||
|
#include "CStopwatch.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
|
#define PAUSE_TIME_HACK 0.1
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
const size_t CFileChunker::m_chunkSize = 512 * 1024; // 512kb
|
const size_t CFileChunker::m_chunkSize = 512 * 1024; // 512kb
|
||||||
|
@ -57,8 +60,11 @@ CFileChunker::sendFileChunks(char* filename, IEventQueue* events, void* eventTar
|
||||||
// send chunk messages with a fixed chunk size
|
// send chunk messages with a fixed chunk size
|
||||||
size_t sentLength = 0;
|
size_t sentLength = 0;
|
||||||
size_t chunkSize = m_chunkSize;
|
size_t chunkSize = m_chunkSize;
|
||||||
|
CStopwatch stopwatch;
|
||||||
|
stopwatch.start();
|
||||||
file.seekg (0, std::ios::beg);
|
file.seekg (0, std::ios::beg);
|
||||||
while (true) {
|
while (true) {
|
||||||
|
if (stopwatch.getTime() > PAUSE_TIME_HACK) {
|
||||||
// make sure we don't read too much from the mock data.
|
// make sure we don't read too much from the mock data.
|
||||||
if (sentLength + chunkSize > size) {
|
if (sentLength + chunkSize > size) {
|
||||||
chunkSize = size - sentLength;
|
chunkSize = size - sentLength;
|
||||||
|
@ -79,6 +85,9 @@ CFileChunker::sendFileChunks(char* filename, IEventQueue* events, void* eventTar
|
||||||
if (sentLength == size) {
|
if (sentLength == size) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stopwatch.reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// send last message
|
// send last message
|
||||||
|
|
Loading…
Reference in New Issue