mirror of
https://github.com/debauchee/barrier.git
synced 2025-07-21 02:17:37 +02:00
Patch by Jerry for issue 46:
- Unit test for sending file data from server to client. - Removed singleton pattern from CSocketMultiplexer for easier unit testing. - Incremented protocol version from 1.4 to 1.5 (new file chunk message). - Storing pointer to CConfig instead of copying in CServer (so we can mock it). - Created a common event queue for testing (timeout, quit event, etc). - Fixed code style.
This commit is contained in:
parent
6f97f1d186
commit
c368013f13
56 changed files with 830 additions and 165 deletions
|
@ -30,11 +30,12 @@
|
|||
#include "CLog.h"
|
||||
#include "IEventQueue.h"
|
||||
#include "TMethodEventJob.h"
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include "CArch.h"
|
||||
#include "IPlatformScreen.h"
|
||||
#include "CCryptoStream.h"
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <sstream>
|
||||
|
||||
//
|
||||
// CClient
|
||||
|
@ -83,6 +84,10 @@ CClient::CClient(IEventQueue* events,
|
|||
getEventTarget(),
|
||||
new TMethodEventJob<CClient>(this,
|
||||
&CClient::handleGameDeviceFeedback));
|
||||
m_events->adoptHandler(m_events->forIScreen().fileChunkSending(),
|
||||
this,
|
||||
new TMethodEventJob<CClient>(this,
|
||||
&CClient::handleFileChunkSending));
|
||||
}
|
||||
|
||||
CClient::~CClient()
|
||||
|
@ -728,3 +733,33 @@ CClient::handleGameDeviceFeedback(const CEvent& event, void*)
|
|||
|
||||
m_server->onGameDeviceFeedback(info->m_id, info->m_m1, info->m_m2);
|
||||
}
|
||||
|
||||
void
|
||||
CClient::handleFileChunkSending(const CEvent& event, void*)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CClient::clearReceivedFileData()
|
||||
{
|
||||
m_receivedFileData.clear();
|
||||
}
|
||||
|
||||
void
|
||||
CClient::setExpectedFileSize(CString data)
|
||||
{
|
||||
std::istringstream iss(data);
|
||||
iss >> m_expectedFileSize;
|
||||
}
|
||||
|
||||
void
|
||||
CClient::fileChunkReceived(CString data)
|
||||
{
|
||||
m_receivedFileData += data;
|
||||
}
|
||||
|
||||
bool
|
||||
CClient::isReceivedFileSizeValid()
|
||||
{
|
||||
return m_expectedFileSize == m_receivedFileData.size();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue