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

@@ -15,12 +15,13 @@
#include <memory>
#include <mutex>
#include <string>
#include <thread>
#include <vector>
#include "llvm/StringRef.h"
#include "IDispatcher.h"
#include "NetworkConnection.h"
#include "INetworkConnection.h"
namespace wpi {
class Logger;
@@ -32,6 +33,7 @@ namespace nt {
class IConnectionNotifier;
class IStorage;
class NetworkConnection;
class DispatcherBase : public IDispatcher {
friend class DispatcherTest;
@@ -79,8 +81,8 @@ class DispatcherBase : public IDispatcher {
void ClientReconnect(unsigned int proto_rev = 0x0300);
void QueueOutgoing(std::shared_ptr<Message> msg, NetworkConnection* only,
NetworkConnection* except) override;
void QueueOutgoing(std::shared_ptr<Message> msg, INetworkConnection* only,
INetworkConnection* except) override;
IStorage& m_storage;
IConnectionNotifier& m_notifier;
@@ -96,7 +98,7 @@ class DispatcherBase : public IDispatcher {
// Mutex for user-accessible items
mutable std::mutex m_user_mutex;
std::vector<std::shared_ptr<NetworkConnection>> m_connections;
std::vector<std::shared_ptr<INetworkConnection>> m_connections;
std::string m_identity;
std::atomic_bool m_active; // set to false to terminate threads