make EnetConnection non copyable
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <Nazara/Network/ENetHost.hpp>
|
#include <Nazara/Network/ENetHost.hpp>
|
||||||
#include <blitz/common/NonCopyable.h>
|
|
||||||
#include <blitz/network/EnetConnexion.h>
|
#include <blitz/network/EnetConnexion.h>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <Nazara/Core/ByteArray.hpp>
|
#include <Nazara/Core/ByteArray.hpp>
|
||||||
#include <NazaraUtils/Signal.hpp>
|
#include <NazaraUtils/Signal.hpp>
|
||||||
|
#include <blitz/common/NonCopyable.h>
|
||||||
#include <blitz/protocol/PacketData.h>
|
#include <blitz/protocol/PacketData.h>
|
||||||
#include <blitz/protocol/PacketDeclare.h>
|
#include <blitz/protocol/PacketDeclare.h>
|
||||||
|
|
||||||
@@ -34,7 +35,7 @@ class EnetServer;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
class EnetConnexion {
|
class EnetConnexion : private NonCopyable {
|
||||||
public:
|
public:
|
||||||
EnetConnexion(Nz::ENetPeer* a_Peer = nullptr);
|
EnetConnexion(Nz::ENetPeer* a_Peer = nullptr);
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include <Nazara/Core/ThreadExt.hpp>
|
#include <Nazara/Core/ThreadExt.hpp>
|
||||||
#include <Nazara/Network/ENetHost.hpp>
|
#include <Nazara/Network/ENetHost.hpp>
|
||||||
#include <blitz/common/NonCopyable.h>
|
|
||||||
#include <blitz/network/EnetConnexion.h>
|
#include <blitz/network/EnetConnexion.h>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <map>
|
#include <map>
|
||||||
@@ -35,7 +34,7 @@ class EnetServer : private NonCopyable {
|
|||||||
Nz::ENetHost m_Host;
|
Nz::ENetHost m_Host;
|
||||||
bool m_Running;
|
bool m_Running;
|
||||||
std::thread m_Thread;
|
std::thread m_Thread;
|
||||||
std::map<std::uint16_t, EnetConnexion> m_Connexion;
|
std::map<std::uint16_t, std::unique_ptr<EnetConnexion>> m_Connexion;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace network
|
} // namespace network
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ void EnetServer::Update() {
|
|||||||
|
|
||||||
case Nz::ENetEventType::IncomingConnect: {
|
case Nz::ENetEventType::IncomingConnect: {
|
||||||
Nz::ENetPeer* peer = event.peer;
|
Nz::ENetPeer* peer = event.peer;
|
||||||
m_Connexion.insert({peer->GetPeerId(), EnetConnexion(peer)});
|
auto con = std::make_unique<EnetConnexion>(peer);
|
||||||
|
m_Connexion.insert({peer->GetPeerId(), std::move(con)});
|
||||||
OnClientConnect(*GetConnexion(peer->GetPeerId()));
|
OnClientConnect(*GetConnexion(peer->GetPeerId()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -73,7 +74,7 @@ EnetConnexion* EnetServer::GetConnexion(std::uint16_t a_PeerId) {
|
|||||||
if (it == m_Connexion.end())
|
if (it == m_Connexion.end())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return &it->second;
|
return it->second.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*void EnetServer::BroadcastPacket(const protocol::Packet& a_Packet, Nz::ENetPacketFlags a_Flags) {
|
/*void EnetServer::BroadcastPacket(const protocol::Packet& a_Packet, Nz::ENetPacketFlags a_Flags) {
|
||||||
|
|||||||
Reference in New Issue
Block a user