Add NetworkDriver interface pointer to NetworkConfig

This commit is contained in:
Damian Korczowski
2021-10-12 18:18:57 +02:00
parent ea05fa8f69
commit e717d29401
2 changed files with 10 additions and 3 deletions

View File

@@ -4,6 +4,8 @@
#include "Engine/Platform/Network.h"
class PersistentScriptingObject;
/// <summary>
/// Network driver implementations enum.
/// </summary>
@@ -33,7 +35,12 @@ public:
/// </summary>
API_FIELD()
NetworkDriverType NetworkDriverType = NetworkDriverType::ENet;
// TODO: Expose INetworkDriver as a ref not enum, when C++/C# interfaces are done.
/// <summary>
/// The network driver instance that will be used to create and manage the peer, send and receive messages.
/// </summary>
API_FIELD()
PersistentScriptingObject* NetworkDriver = nullptr;
public:
/// <summary>

View File

@@ -20,7 +20,7 @@ void NetworkPeer::Initialize(const NetworkConfig& config)
Config = config;
ASSERT(NetworkDriver == nullptr);
ASSERT(Config.NetworkDriverType != NetworkDriverType::Undefined);
ASSERT(Config.NetworkDriver != nullptr);
ASSERT(Config.ConnectionsLimit > 0);
ASSERT(Config.MessageSize > 32); // TODO: Adjust this, not sure what the lowest limit should be.
ASSERT(Config.MessagePoolSize > 128);
@@ -35,7 +35,7 @@ void NetworkPeer::Initialize(const NetworkConfig& config)
MessagePool.Push(messageId);
// Setup network driver
NetworkDriver = New<ENetDriver>();
NetworkDriver = ToInterface<INetworkDriver>(Config.NetworkDriver);
NetworkDriver->Initialize(this, Config);
LOG(Info, "NetworkManager initialized using driver = {0}", static_cast<int>(Config.NetworkDriverType));