Add NetworkDriver interface pointer to NetworkConfig
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user