95 lines
1.7 KiB
C
Raw Normal View History

#pragma once
#include "ehs/io/socket/ehc/NetEnc.h"
#include "ehs/Array.h"
#include "Socket.h"
#include "UDP.h"
namespace ehs
{
class NetServerCh;
class NetClientCh;
class NetEnd;
class EHC;
class EHC
{
private:
friend class NetEnc;
friend class NetChannel;
friend class NetServerCh;
friend class NetClientCh;
friend class NetEnd;
static const Version version;
UDP udp;
Byte* buffer;
UInt_32 bufferSize;
UInt_64 lastTSC;
float delta;
Array<NetEnc *> encryptions;
Array<NetServerCh *> servers;
Array<NetClientCh *> clients;
public:
~EHC();
EHC(IP version = IP::V6);
EHC(EHC &&sock) noexcept;
EHC(const EHC &sock);
EHC &operator=(EHC&& sock) noexcept;
EHC &operator=(const EHC &sock);
void Initialize();
void Release();
void Bind(const Endpoint &endpoint);
void Poll();
bool IsInitialized() const;
Endpoint GetLocalEndpoint() const;
bool IsBound() const;
static Version GetVersion();
bool AddEncryption(NetEnc *enc);
bool HasServer(UInt_64 serverId) const;
bool HasServer(const Str_8& serverName) const;
2025-01-30 12:32:52 -08:00
bool AddServer(NetServerCh *server);
NetServerCh *GetServer(UInt_64 serverId) const;
NetServerCh *GetServer(const Str_8& serverName) const;
bool HasClient(UInt_64 clientId) const;
bool HasClient(const Str_8& clientName) const;
2025-01-30 12:32:52 -08:00
bool AddClient(NetClientCh *channel);
NetClientCh *GetClient(UInt_64 clientId) const;
NetClientCh *GetClient(const Str_8& clientName) const;
2025-01-30 12:32:52 -08:00
private:
bool HasEncryption(UInt_64 encId) const;
bool HasEncryption(const Str_8& encName) const;
NetEnc* GetEncryption(UInt_64 encId) const;
NetEnc* GetEncryption(const Str_8& encName) const;
};
}