diff --git a/Source/Engine/Networking/Drivers/ENetDriver.cpp b/Source/Engine/Networking/Drivers/ENetDriver.cpp index e8f812a3f..ed7ebbb84 100644 --- a/Source/Engine/Networking/Drivers/ENetDriver.cpp +++ b/Source/Engine/Networking/Drivers/ENetDriver.cpp @@ -57,7 +57,7 @@ void ENetDriver::Initialize(NetworkPeer* host, const NetworkConfig& config) { _networkHost = host; _config = config; - _peerMap = Dictionary(); + _peerMap = Dictionary(); if (enet_initialize () != 0) { LOG(Error, "Failed to initialize ENet driver!"); @@ -173,7 +173,7 @@ bool ENetDriver::PopEvent(NetworkEvent* eventPtr) if(result > 0) { // Copy sender data - const uint32_t connectionId = enet_peer_get_id(event.peer); + const uint32 connectionId = enet_peer_get_id(event.peer); eventPtr->Sender = NetworkConnection(); eventPtr->Sender.ConnectionId = connectionId; @@ -189,14 +189,14 @@ bool ENetDriver::PopEvent(NetworkEvent* eventPtr) case ENET_EVENT_TYPE_DISCONNECT: eventPtr->EventType = NetworkEventType::Disconnected; - if(IsServer() && _peerMap.ContainsKey(connectionId)) + if(IsServer()) _peerMap.Remove(connectionId); break; case ENET_EVENT_TYPE_DISCONNECT_TIMEOUT: eventPtr->EventType = NetworkEventType::Timeout; - if(IsServer() && _peerMap.ContainsKey(connectionId)) + if(IsServer()) _peerMap.Remove(connectionId); break; @@ -235,7 +235,7 @@ void ENetDriver::SendMessage(NetworkChannelType channelType, const NetworkMessag SendPacketToPeer(peer, channelType, message); } -void ENetDriver::SendMessage(const NetworkChannelType channelType, const NetworkMessage& message, Array targets) +void ENetDriver::SendMessage(const NetworkChannelType channelType, const NetworkMessage& message, Array& targets) { ASSERT(IsServer()); diff --git a/Source/Engine/Networking/Drivers/ENetDriver.h b/Source/Engine/Networking/Drivers/ENetDriver.h index b3096e716..22e924c7e 100644 --- a/Source/Engine/Networking/Drivers/ENetDriver.h +++ b/Source/Engine/Networking/Drivers/ENetDriver.h @@ -29,7 +29,7 @@ public: void SendMessage(NetworkChannelType channelType, const NetworkMessage& message) override; void SendMessage(NetworkChannelType channelType, const NetworkMessage& message, NetworkConnection target) override; - void SendMessage(NetworkChannelType channelType, const NetworkMessage& message, Array targets) override; + void SendMessage(NetworkChannelType channelType, const NetworkMessage& message, Array& targets) override; private: bool IsServer() const @@ -43,6 +43,6 @@ private: void* _host = nullptr; void* _peer = nullptr; - Dictionary _peerMap; + Dictionary _peerMap; }; diff --git a/Source/Engine/Networking/INetworkDriver.h b/Source/Engine/Networking/INetworkDriver.h index 810f4e046..da1503132 100644 --- a/Source/Engine/Networking/INetworkDriver.h +++ b/Source/Engine/Networking/INetworkDriver.h @@ -11,7 +11,16 @@ API_INTERFACE(Namespace="FlaxEngine.Networking") class FLAXENGINE_API INetworkDriver { DECLARE_SCRIPTING_TYPE_MINIMAL(INetworkDriver); + public: + + /// + /// Finalizes an instance of the class. + /// + virtual ~INetworkDriver() = default; + +public: + /// /// Initializes the instance of this network driver using given configuration. /// @@ -93,7 +102,7 @@ public: /// Do not recycle the message after calling this. /// This function automatically recycles the message. /// - virtual void SendMessage(NetworkChannelType channelType, const NetworkMessage& message, Array targets) = 0; + virtual void SendMessage(NetworkChannelType channelType, const NetworkMessage& message, Array& targets) = 0; // TODO: Stats API // TODO: Simulation API diff --git a/Source/Engine/Networking/NetworkChannelType.h b/Source/Engine/Networking/NetworkChannelType.h index e5fbc8d9b..42fecb938 100644 --- a/Source/Engine/Networking/NetworkChannelType.h +++ b/Source/Engine/Networking/NetworkChannelType.h @@ -2,7 +2,7 @@ #pragma once -#include "Engine/Scripting/ScriptingType.h" +#include "Engine/Core/Config.h" /// /// The low-level network channel type for message sending. diff --git a/Source/Engine/Networking/NetworkPeer.cpp b/Source/Engine/Networking/NetworkPeer.cpp index 407650dc1..c9c14c821 100644 --- a/Source/Engine/Networking/NetworkPeer.cpp +++ b/Source/Engine/Networking/NetworkPeer.cpp @@ -12,7 +12,7 @@ namespace { Array Peers; - uint32_t LastHostId = 0; + uint32 LastHostId = 0; } void NetworkPeer::Initialize(const NetworkConfig& config) @@ -153,7 +153,7 @@ bool NetworkPeer::EndSendMessage(const NetworkChannelType channelType, const Net return false; } -bool NetworkPeer::EndSendMessage(const NetworkChannelType channelType, const NetworkMessage& message, Array targets) +bool NetworkPeer::EndSendMessage(const NetworkChannelType channelType, const NetworkMessage& message, Array& targets) { ASSERT(message.IsValid()); diff --git a/Source/Engine/Networking/NetworkPeer.h b/Source/Engine/Networking/NetworkPeer.h index 4bb684be4..e89a46eff 100644 --- a/Source/Engine/Networking/NetworkPeer.h +++ b/Source/Engine/Networking/NetworkPeer.h @@ -149,7 +149,7 @@ public: /// This function automatically recycles the message. /// API_FUNCTION() - bool EndSendMessage(NetworkChannelType channelType, const NetworkMessage& message, Array targets); + bool EndSendMessage(NetworkChannelType channelType, const NetworkMessage& message, Array& targets); public: ///