diff --git a/src/lib/client/CClient.cpp b/src/lib/client/CClient.cpp index a5cbc3cf..9f73aea5 100644 --- a/src/lib/client/CClient.cpp +++ b/src/lib/client/CClient.cpp @@ -46,8 +46,6 @@ // CClient // -const size_t CClient::m_chunkSize = 1024 * 512; // 512kb - CClient::CClient(IEventQueue* events, const CString& name, const CNetworkAddress& address, ISocketFactory* socketFactory, diff --git a/src/lib/client/CClient.h b/src/lib/client/CClient.h index 5d93143d..e2aea037 100644 --- a/src/lib/client/CClient.h +++ b/src/lib/client/CClient.h @@ -222,7 +222,6 @@ private: CCryptoOptions m_crypto; std::size_t m_expectedFileSize; CString m_receivedFileData; - static const size_t m_chunkSize; }; #endif diff --git a/src/lib/server/CServer.cpp b/src/lib/server/CServer.cpp index 15d863fe..9ffc70cc 100644 --- a/src/lib/server/CServer.cpp +++ b/src/lib/server/CServer.cpp @@ -48,8 +48,6 @@ // CServer // -const size_t CServer::m_chunkSize = 1024 * 512; // 512kb - CServer::CServer(CConfig& config, CPrimaryClient* primaryClient, CScreen* screen, IEventQueue* events) : m_events(events), m_mock(false), diff --git a/src/lib/server/CServer.h b/src/lib/server/CServer.h index da4edbeb..b2802a0b 100644 --- a/src/lib/server/CServer.h +++ b/src/lib/server/CServer.h @@ -468,7 +468,6 @@ private: // file transfer size_t m_expectedFileSize; CString m_receivedFileData; - static const size_t m_chunkSize; CString m_fileTransferSrc; CString m_fileTransferDes; }; diff --git a/src/lib/synergy/CFileChunker.cpp b/src/lib/synergy/CFileChunker.cpp index 40bb5429..fb9efe92 100644 --- a/src/lib/synergy/CFileChunker.cpp +++ b/src/lib/synergy/CFileChunker.cpp @@ -22,10 +22,13 @@ #include "IEventQueue.h" #include "CEventTypes.h" #include "CLog.h" +#include "CStopwatch.h" #include #include #include +#define PAUSE_TIME_HACK 0.1 + using namespace std; const size_t CFileChunker::m_chunkSize = 512 * 1024; // 512kb @@ -57,27 +60,33 @@ CFileChunker::sendFileChunks(char* filename, IEventQueue* events, void* eventTar // send chunk messages with a fixed chunk size size_t sentLength = 0; size_t chunkSize = m_chunkSize; + CStopwatch stopwatch; + stopwatch.start(); file.seekg (0, std::ios::beg); while (true) { - // make sure we don't read too much from the mock data. - if (sentLength + chunkSize > size) { - chunkSize = size - sentLength; - } + if (stopwatch.getTime() > PAUSE_TIME_HACK) { + // make sure we don't read too much from the mock data. + if (sentLength + chunkSize > size) { + chunkSize = size - sentLength; + } - // for fileChunk->m_chunk, the first byte is the chunk mark, last is \0 - CFileChunk* fileChunk = new CFileChunk(chunkSize + 2); - char* chunkData = fileChunk->m_chunk; + // for fileChunk->m_chunk, the first byte is the chunk mark, last is \0 + CFileChunk* fileChunk = new CFileChunk(chunkSize + 2); + char* chunkData = fileChunk->m_chunk; - chunkData[0] = kFileChunk; - file.read(&chunkData[1], chunkSize); - chunkData[chunkSize + 1] = '\0'; - events->addEvent(CEvent(events->forIScreen().fileChunkSending(), eventTarget, fileChunk)); + chunkData[0] = kFileChunk; + file.read(&chunkData[1], chunkSize); + chunkData[chunkSize + 1] = '\0'; + events->addEvent(CEvent(events->forIScreen().fileChunkSending(), eventTarget, fileChunk)); - sentLength += chunkSize; - file.seekg (sentLength, std::ios::beg); + sentLength += chunkSize; + file.seekg (sentLength, std::ios::beg); - if (sentLength == size) { - break; + if (sentLength == size) { + break; + } + + stopwatch.reset(); } }