Use enum instead interface reference for now

This commit is contained in:
Damian Korczowski
2021-03-11 18:47:05 +01:00
parent 393595ea2d
commit 43e8a54e57
2 changed files with 14 additions and 5 deletions

View File

@@ -2,12 +2,20 @@
#pragma once
API_ENUM(Namespace="FlaxEngine.Networking") enum class NetworkTransportType
{
Undefined = 0,
ENet
};
API_STRUCT(Namespace="FlaxEngine.Networking") struct FLAXENGINE_API NetworkConfig
{
DECLARE_SCRIPTING_TYPE_MINIMAL(NetworkConfig);
public:
API_FIELD()
INetworkDriver* NetworkDriver = nullptr; // TODO: Pass by ref not pointer (?)
NetworkTransportType NetworkDriverType = NetworkTransportType::ENet;
// TODO: Expose INetworkDriver as a ref not enum, when C++/C# interfaces are done.
public:
API_FIELD()

View File

@@ -7,7 +7,8 @@
#include "NetworkConnection.h"
#include "INetworkDriver.h"
#include "Engine/Core/Core.h"
#include "Drivers/ENetDriver.h"
#include "Engine/Core/Collections/Array.h"
#include "Engine/Core/Math/Math.h"
#include "Engine/Platform/CPUInfo.h"
@@ -26,7 +27,7 @@ bool NetworkManager::Initialize(const NetworkConfig& config)
Config = config;
ASSERT(NetworkDriver == nullptr);
ASSERT(Config.NetworkDriver);
ASSERT(Config.NetworkDriverType != NetworkTransportType::Undefined);
ASSERT(Config.ConnectionsLimit > 0);
ASSERT(Config.MessageSize > 32); // TODO: Adjust this, not sure what the lowest limit should be.
ASSERT(Config.MessagePoolSize > 128);
@@ -40,7 +41,7 @@ bool NetworkManager::Initialize(const NetworkConfig& config)
MessagePool.Push(messageId);
// Setup network driver
NetworkDriver = Config.NetworkDriver;
NetworkDriver = New<ENetDriver>();
NetworkDriver->Initialize(Config);
return false;
@@ -48,7 +49,7 @@ bool NetworkManager::Initialize(const NetworkConfig& config)
void NetworkManager::Shutdown()
{
SAFE_DISPOSE(NetworkDriver);
Delete(NetworkDriver);
DisposeMessageBuffers();
}