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:
Nick Bolton 2013-07-16 19:02:30 +00:00
parent 6f97f1d186
commit c368013f13
56 changed files with 830 additions and 165 deletions

View file

@ -35,11 +35,12 @@
// CTCPSocket
//
CTCPSocket::CTCPSocket(IEventQueue* events) :
CTCPSocket::CTCPSocket(IEventQueue* events, CSocketMultiplexer* socketMultiplexer) :
IDataSocket(events),
m_events(events),
m_mutex(),
m_flushed(&m_mutex, true)
m_flushed(&m_mutex, true),
m_socketMultiplexer(socketMultiplexer)
{
try {
m_socket = ARCH->newSocket(IArchNetwork::kINET, IArchNetwork::kSTREAM);
@ -51,12 +52,13 @@ CTCPSocket::CTCPSocket(IEventQueue* events) :
init();
}
CTCPSocket::CTCPSocket(IEventQueue* events, CArchSocket socket) :
CTCPSocket::CTCPSocket(IEventQueue* events, CSocketMultiplexer* socketMultiplexer, CArchSocket socket) :
IDataSocket(events),
m_events(events),
m_mutex(),
m_socket(socket),
m_flushed(&m_mutex, true)
m_flushed(&m_mutex, true),
m_socketMultiplexer(socketMultiplexer)
{
assert(m_socket != NULL);
@ -316,10 +318,10 @@ CTCPSocket::setJob(ISocketMultiplexerJob* job)
{
// multiplexer will delete the old job
if (job == NULL) {
CSocketMultiplexer::getInstance()->removeSocket(this);
m_socketMultiplexer->removeSocket(this);
}
else {
CSocketMultiplexer::getInstance()->addSocket(this, job);
m_socketMultiplexer->addSocket(this, job);
}
}