diff --git a/ChangeLog.md b/ChangeLog.md index a60af1b03..e87ec785e 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -220,6 +220,7 @@ Nazara Engine: - ⚠ Removed Texture(const Image\*) constructor, use Texture::LoadFromImage instead - ⚠ TextDrawers now use floating-point internally and to exposes their Bounds (AbstractTextDrawer::GetBounds() now returns a Rectf) - Added [SimpleTextDrawer|RichTextDrawer] character and line spacing offset properties +- Added ENetHost::AllowsIncomingConnections(bool) to disable/re-enable server peers connection Nazara Development Kit: - Added ImageWidget (#139) diff --git a/include/Nazara/Network/ENetHost.hpp b/include/Nazara/Network/ENetHost.hpp index 01f59234b..b6af25895 100644 --- a/include/Nazara/Network/ENetHost.hpp +++ b/include/Nazara/Network/ENetHost.hpp @@ -44,6 +44,8 @@ namespace Nz ENetHost(ENetHost&&) = default; inline ~ENetHost(); + inline void AllowsIncomingConnections(bool allow = true); + void Broadcast(UInt8 channelId, ENetPacketFlags flags, NetPacket&& packet); bool CheckEvents(ENetEvent* event); @@ -56,6 +58,8 @@ namespace Nz bool Create(const IpAddress& listenAddress, std::size_t peerCount, std::size_t channelCount, UInt32 incomingBandwidth, UInt32 outgoingBandwidth); inline void Destroy(); + inline bool DoesAllowIncomingConnections() const; + void Flush(); inline IpAddress GetBoundAddress() const; diff --git a/include/Nazara/Network/ENetHost.inl b/include/Nazara/Network/ENetHost.inl index fcb6bf6de..fadcc9fc4 100644 --- a/include/Nazara/Network/ENetHost.inl +++ b/include/Nazara/Network/ENetHost.inl @@ -20,6 +20,13 @@ namespace Nz Destroy(); } + inline void ENetHost::AllowsIncomingConnections(bool allow) + { + NazaraAssert(m_address.IsValid() && !m_address.IsLoopback(), "Only server hosts can allow incoming connections"); + + m_allowsIncomingConnections = allow; + } + inline bool ENetHost::Create(NetProtocol protocol, UInt16 port, std::size_t peerCount, std::size_t channelCount) { NazaraAssert(protocol != NetProtocol_Unknown, "Invalid protocol"); @@ -54,6 +61,11 @@ namespace Nz m_socket.Close(); } + inline bool ENetHost::DoesAllowIncomingConnections() const + { + return m_allowsIncomingConnections; + } + inline IpAddress ENetHost::GetBoundAddress() const { return m_address;