diff --git a/Source/Engine/Networking/Drivers/ENetDriver.h b/Source/Engine/Networking/Drivers/ENetDriver.h
index e951b6fb2..97a1949f6 100644
--- a/Source/Engine/Networking/Drivers/ENetDriver.h
+++ b/Source/Engine/Networking/Drivers/ENetDriver.h
@@ -19,6 +19,7 @@ DECLARE_SCRIPTING_TYPE(ENetDriver);
public:
// [INetworkDriver]
+ String DriverName() override { return String("ENetDriver"); }
void Initialize(NetworkPeer* host, const NetworkConfig& config) override;
void Dispose() override;
bool Listen() override;
diff --git a/Source/Engine/Networking/INetworkDriver.h b/Source/Engine/Networking/INetworkDriver.h
index 2908f0d5f..63ec64557 100644
--- a/Source/Engine/Networking/INetworkDriver.h
+++ b/Source/Engine/Networking/INetworkDriver.h
@@ -3,6 +3,7 @@
#pragma once
#include "Types.h"
+#include "Engine/Core/Types/String.h"
#include "Engine/Scripting/ScriptingType.h"
///
@@ -18,6 +19,14 @@ public:
///
virtual ~INetworkDriver() = default;
+ ///
+ /// Return name of this network driver implementation.
+ ///
+ API_FUNCTION() virtual String DriverName()
+ {
+ return String("Unknown");
+ }
+
///
/// Initializes the instance of this network driver using given configuration.
///
diff --git a/Source/Engine/Networking/NetworkConfig.h b/Source/Engine/Networking/NetworkConfig.h
index 8814759db..31f6a5d6f 100644
--- a/Source/Engine/Networking/NetworkConfig.h
+++ b/Source/Engine/Networking/NetworkConfig.h
@@ -4,10 +4,12 @@
#include "Engine/Platform/Network.h"
+class PersistentScriptingObject;
+
///
/// Network driver implementations enum.
///
-API_ENUM(Namespace="FlaxEngine.Networking") enum class NetworkDriverType
+API_ENUM(Namespace="FlaxEngine.Networking") enum class DEPRECATED NetworkDriverType
{
///
/// Invalid network driver implementation.
@@ -32,8 +34,13 @@ public:
/// To allow two peers to connect, they must use the same host.
///
API_FIELD()
- NetworkDriverType NetworkDriverType = NetworkDriverType::ENet;
- // TODO: Expose INetworkDriver as a ref not enum, when C++/C# interfaces are done.
+ DEPRECATED NetworkDriverType NetworkDriverType = NetworkDriverType::ENet;
+
+ ///
+ /// The network driver instance that will be used to create and manage the peer, send and receive messages.
+ ///
+ API_FIELD()
+ PersistentScriptingObject* NetworkDriver = nullptr;
public:
///
diff --git a/Source/Engine/Networking/NetworkPeer.cpp b/Source/Engine/Networking/NetworkPeer.cpp
index 52bc72776..2e885e54d 100644
--- a/Source/Engine/Networking/NetworkPeer.cpp
+++ b/Source/Engine/Networking/NetworkPeer.cpp
@@ -20,10 +20,10 @@ 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);
+ ASSERT(Config.MessagePoolSize > 128);
// TODO: Dynamic message pool allocation
// Setup messages
@@ -35,10 +35,10 @@ void NetworkPeer::Initialize(const NetworkConfig& config)
MessagePool.Push(messageId);
// Setup network driver
- NetworkDriver = New();
+ NetworkDriver = ToInterface(Config.NetworkDriver);
NetworkDriver->Initialize(this, Config);
- LOG(Info, "NetworkManager initialized using driver = {0}", static_cast(Config.NetworkDriverType));
+ LOG(Info, "NetworkManager initialized using driver = {0}", NetworkDriver->DriverName());
}
void NetworkPeer::Shutdown()