57 lines
1.3 KiB
C++
57 lines
1.3 KiB
C++
#pragma once
|
|
|
|
/**
|
|
* \file EnetConnexion.h
|
|
* \brief File containing the blitz::network::EnetConnexion class
|
|
*/
|
|
|
|
#include <NazaraUtils/Signal.hpp>
|
|
#include <blitz/protocol/PacketSerializer.h>
|
|
|
|
namespace Nz {
|
|
|
|
class ENetPeer;
|
|
|
|
} // namespace Nz
|
|
|
|
namespace blitz {
|
|
namespace network {
|
|
|
|
class EnetClient;
|
|
class EnetServer;
|
|
|
|
|
|
|
|
#define DeclarePacket(PacketName, ...) \
|
|
/** Sends a PacketName over the network */ \
|
|
void Send##PacketName(const blitz::protocol::data::PacketName& a_##PacketName) const; \
|
|
/** Use On##PacketName.Connect() to process a PacketName incoming from network */ \
|
|
NazaraSignal(On##PacketName, const blitz::protocol::data::PacketName&);
|
|
|
|
|
|
|
|
|
|
|
|
class EnetConnexion {
|
|
public:
|
|
EnetConnexion(Nz::ENetPeer* a_Peer = nullptr);
|
|
|
|
bool IsConnected() const;
|
|
|
|
DeclareAllPacket();
|
|
|
|
private:
|
|
Nz::ENetPeer* m_Peer;
|
|
|
|
void Recieve(Nz::ByteArray&);
|
|
void SetPeer(Nz::ENetPeer* a_Peer);
|
|
|
|
friend class EnetClient;
|
|
friend class EnetServer;
|
|
};
|
|
|
|
#undef DeclarePacket
|
|
|
|
} // namespace network
|
|
} // namespace blitz
|