From 16b56a7084b588fbaf33407e9360097ac93badf1 Mon Sep 17 00:00:00 2001 From: Arron Nelson Date: Thu, 30 Jan 2025 12:32:52 -0800 Subject: [PATCH] Made NetChannel methods public in EHC. --- include/ehs/io/socket/EHC.h | 26 ++++----- src/io/socket/EHC.cpp | 104 ++++++++++++++++++------------------ 2 files changed, 65 insertions(+), 65 deletions(-) diff --git a/include/ehs/io/socket/EHC.h b/include/ehs/io/socket/EHC.h index e009c6a..ad44975 100644 --- a/include/ehs/io/socket/EHC.h +++ b/include/ehs/io/socket/EHC.h @@ -63,23 +63,12 @@ namespace ehs bool AddEncryption(NetEnc *enc); - bool AddServer(NetServerCh *server); - - bool AddClient(NetClientCh *channel); - - 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; - bool HasServer(UInt_64 serverId) const; bool HasServer(const Str_8& serverName) const; + bool AddServer(NetServerCh *server); + NetServerCh *GetServer(UInt_64 serverId) const; NetServerCh *GetServer(const Str_8& serverName) const; @@ -88,8 +77,19 @@ namespace ehs bool HasClient(const Str_8& clientName) const; + bool AddClient(NetClientCh *channel); + NetClientCh *GetClient(UInt_64 clientId) const; NetClientCh *GetClient(const Str_8& clientName) const; + + 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; }; } \ No newline at end of file diff --git a/src/io/socket/EHC.cpp b/src/io/socket/EHC.cpp index 9b16c0e..45c7668 100644 --- a/src/io/socket/EHC.cpp +++ b/src/io/socket/EHC.cpp @@ -270,58 +270,6 @@ namespace ehs return true; } - bool EHC::AddServer(NetServerCh *server) - { - if (HasServer(server->GetId())) - return false; - - server->owner = this; - - servers.Push(server); - - return true; - } - - bool EHC::AddClient(NetClientCh *client) - { - if (HasServer(client->GetId())) - return false; - - client->owner = this; - - clients.Push(client); - - return true; - } - - bool EHC::HasEncryption(UInt_64 encId) const - { - for (UInt_64 i = 0; i < encryptions.Size(); ++i) - if (encryptions[i]->GetId() == encId) - return true; - - return false; - } - - bool EHC::HasEncryption(const Str_8& encName) const - { - return HasEncryption(encName.Hash_64()); - } - - NetEnc* EHC::GetEncryption(UInt_64 encId) const - { - for (UInt_64 i = 0; i < encryptions.Size(); ++i) - if (encryptions[i]->GetId() == encId) - return encryptions[i]; - - return nullptr; - } - - NetEnc* EHC::GetEncryption(const Str_8& encName) const - { - return GetEncryption(encName.Hash_64()); - } - bool EHC::HasServer(const UInt_64 serverId) const { for (UInt_64 i = 0; i < servers.Size(); ++i) @@ -336,6 +284,18 @@ namespace ehs return HasServer(serverName.Hash_64()); } + bool EHC::AddServer(NetServerCh *server) + { + if (HasServer(server->GetId())) + return false; + + server->owner = this; + + servers.Push(server); + + return true; + } + NetServerCh *EHC::GetServer(const UInt_64 serverId) const { for (UInt_64 i = 0; i < servers.Size(); ++i) @@ -364,6 +324,18 @@ namespace ehs return HasClient(clientName.Hash_64()); } + bool EHC::AddClient(NetClientCh *client) + { + if (HasServer(client->GetId())) + return false; + + client->owner = this; + + clients.Push(client); + + return true; + } + NetClientCh *EHC::GetClient(const UInt_64 clientId) const { for (UInt_64 i = 0; i < clients.Size(); ++i) @@ -377,4 +349,32 @@ namespace ehs { return GetClient(clientName.Hash_64()); } + + bool EHC::HasEncryption(UInt_64 encId) const + { + for (UInt_64 i = 0; i < encryptions.Size(); ++i) + if (encryptions[i]->GetId() == encId) + return true; + + return false; + } + + bool EHC::HasEncryption(const Str_8& encName) const + { + return HasEncryption(encName.Hash_64()); + } + + NetEnc* EHC::GetEncryption(UInt_64 encId) const + { + for (UInt_64 i = 0; i < encryptions.Size(); ++i) + if (encryptions[i]->GetId() == encId) + return encryptions[i]; + + return nullptr; + } + + NetEnc* EHC::GetEncryption(const Str_8& encName) const + { + return GetEncryption(encName.Hash_64()); + } }