Files
NazaraEngine/include/Nazara/Network/ENetHost.inl
Gawaboumga bbac0838dd Include-What-You-Use (#137)
* IWYU Core

* IWYU Noise

* IWYU Utility

* IWYU Audio

* IWYU Platform

* IWYU Lua

* IWYU Network

* IWYU Physics2D

* IWYU Physics3D

* IWYU Renderer

* IWYU Graphics

* IWYU NDKServer

* IWYU Fix

* Try to fix compilation

* Other fixes
2017-10-01 11:17:09 +02:00

79 lines
1.6 KiB
C++

// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Engine - Network module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <utility>
#include <Nazara/Network/Debug.hpp>
namespace Nz
{
inline ENetHost::ENetHost() :
m_packetPool(sizeof(ENetPacket)),
m_isSimulationEnabled(false)
{
}
inline ENetHost::~ENetHost()
{
Destroy();
}
inline bool ENetHost::Create(NetProtocol protocol, UInt16 port, std::size_t peerCount, std::size_t channelCount)
{
NazaraAssert(protocol != NetProtocol_Any, "Any protocol not supported for Listen"); //< TODO
NazaraAssert(protocol != NetProtocol_Unknown, "Invalid protocol");
IpAddress any;
switch (protocol)
{
case NetProtocol_Any:
case NetProtocol_Unknown:
NazaraInternalError("Invalid protocol Any at this point");
return false;
case NetProtocol_IPv4:
any = IpAddress::AnyIpV4;
break;
case NetProtocol_IPv6:
any = IpAddress::AnyIpV6;
break;
}
any.SetPort(port);
return Create(any, peerCount, channelCount);
}
inline void ENetHost::Destroy()
{
m_poller.Clear();
m_peers.clear();
m_socket.Close();
}
inline IpAddress ENetHost::GetBoundAddress() const
{
return m_address;
}
inline UInt32 ENetHost::GetServiceTime() const
{
return m_serviceTime;
}
inline void ENetHost::SetCompressor(std::unique_ptr<ENetCompressor>&& compressor)
{
m_compressor = std::move(compressor);
}
inline ENetPacketRef ENetHost::AllocatePacket(ENetPacketFlags flags, NetPacket&& data)
{
ENetPacketRef ref = AllocatePacket(flags);
ref->data = std::move(data);
return ref;
}
}
#include <Nazara/Network/DebugOff.hpp>