Patch by Jerry:

- Fixed line endings
- Integ test for file transfer
- Fixed crashed problem when log info is larger than 2048 bytes
- Fixed compile error caused by std exception (by Feng ye)
- Fixed include path on Mac and linux (by Feng ye)
This commit is contained in:
Nick Bolton 2013-07-24 16:41:12 +00:00
parent c368013f13
commit 394ece004a
72 changed files with 3884 additions and 3127 deletions

View file

@ -33,14 +33,20 @@
#include "CArch.h"
#include "IPlatformScreen.h"
#include "CCryptoStream.h"
#include "CThread.h"
#include "TMethodJob.h"
#include "CFileChunker.h"
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <fstream>
//
// CClient
//
const size_t CClient::m_chunkSize = 1024 * 512; // 512kb
CClient::CClient(IEventQueue* events,
const CString& name, const CNetworkAddress& address,
ISocketFactory* socketFactory,
@ -438,6 +444,17 @@ CClient::sendConnectionFailedEvent(const char* msg)
m_events->addEvent(event);
}
void
CClient::sendFileChunk(const void* data)
{
CFileChunker::CFileChunk* fileChunk = reinterpret_cast<CFileChunker::CFileChunk*>(const_cast<void*>(data));
LOG((CLOG_DEBUG1 "sendFileChunk"));
assert(m_server != NULL);
// relay
m_server->fileChunkSending(fileChunk->m_chunk[0], &(fileChunk->m_chunk[1]), fileChunk->m_dataSize);
}
void
CClient::setupConnecting()
{
@ -737,6 +754,7 @@ CClient::handleGameDeviceFeedback(const CEvent& event, void*)
void
CClient::handleFileChunkSending(const CEvent& event, void*)
{
sendFileChunk(event.getData());
}
void
@ -763,3 +781,24 @@ CClient::isReceivedFileSizeValid()
{
return m_expectedFileSize == m_receivedFileData.size();
}
void
CClient::sendFileToServer(const char* filename)
{
CThread* thread = new CThread(
new TMethodJob<CClient>(
this, &CClient::sendFileThread,
reinterpret_cast<void*>(const_cast<char*>(filename))));
}
void
CClient::sendFileThread(void* filename)
{
try {
char* name = reinterpret_cast<char*>(filename);
CFileChunker::sendFileChunks(name, m_events, this);
}
catch (std::runtime_error error) {
LOG((CLOG_ERR "failed sending file chunks: %s", error.what()));
}
}