Network/ENetHost: Add AllowsIncomingConnections method

This commit is contained in:
Lynix 2020-02-01 16:36:05 +01:00
parent d435826651
commit 518b8697de
3 changed files with 17 additions and 0 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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;