Add INetworkConnection interface for unit testing.

This commit is contained in:
Peter Johnson
2017-09-04 22:01:59 -07:00
parent 7c1d2f4bc4
commit cedbafeb28
12 changed files with 143 additions and 59 deletions

View File

@@ -16,6 +16,7 @@
#include "IConnectionNotifier.h"
#include "Log.h"
#include "IStorage.h"
#include "NetworkConnection.h"
using namespace nt;
@@ -178,7 +179,7 @@ void DispatcherBase::Stop() {
if (m_dispatch_thread.joinable()) m_dispatch_thread.join();
if (m_clientserver_thread.joinable()) m_clientserver_thread.join();
std::vector<std::shared_ptr<NetworkConnection>> conns;
std::vector<std::shared_ptr<INetworkConnection>> conns;
{
std::lock_guard<std::mutex> lock(m_user_mutex);
conns.swap(m_connections);
@@ -315,8 +316,8 @@ void DispatcherBase::DispatchThreadMain() {
}
void DispatcherBase::QueueOutgoing(std::shared_ptr<Message> msg,
NetworkConnection* only,
NetworkConnection* except) {
INetworkConnection* only,
INetworkConnection* except) {
std::lock_guard<std::mutex> user_lock(m_user_mutex);
for (auto& conn : m_connections) {
if (conn.get() == except) continue;