Added the capability for custom encryption's to be added to EHC.
This commit is contained in:
105
src/io/socket/ehc/NetSys.cpp
Normal file
105
src/io/socket/ehc/NetSys.cpp
Normal file
@@ -0,0 +1,105 @@
|
||||
#include "ehs/io/socket/ehc/NetSys.h"
|
||||
#include "ehs/io/socket/EHC.h"
|
||||
#include "ehs/io/socket/ehc/NetEnd.h"
|
||||
#include "ehs/io/socket/ehc/NetOp.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
NetSys::~NetSys()
|
||||
{
|
||||
for (UInt_64 i = 0; i < ops.Size(); ++i)
|
||||
delete ops[i];
|
||||
|
||||
ops.Clear();
|
||||
}
|
||||
|
||||
NetSys::NetSys()
|
||||
: hashId(0)
|
||||
{
|
||||
}
|
||||
|
||||
NetSys::NetSys(Str_8 id)
|
||||
: hashId(id.Hash_64()), id((Str_8&&)id)
|
||||
{
|
||||
}
|
||||
|
||||
NetSys::NetSys(NetSys&& sys) noexcept
|
||||
: hashId(sys.hashId), id((Str_8&&)sys.id), ops((Array<NetOp*>&&)sys.ops)
|
||||
{
|
||||
sys.hashId = 0;
|
||||
}
|
||||
|
||||
NetSys::NetSys(const NetSys& sys)
|
||||
: hashId(sys.hashId), id(sys.id)
|
||||
{
|
||||
}
|
||||
|
||||
NetSys& NetSys::operator=(NetSys&& sys) noexcept
|
||||
{
|
||||
if (this == &sys)
|
||||
return *this;
|
||||
|
||||
hashId = sys.hashId;
|
||||
id = (Str_8&&)sys.id;
|
||||
ops = (Array<NetOp*>&&)sys.ops;
|
||||
|
||||
sys.hashId = 0;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
NetSys& NetSys::operator=(const NetSys& sys)
|
||||
{
|
||||
if (this == &sys)
|
||||
return *this;
|
||||
|
||||
hashId = sys.hashId;
|
||||
id = sys.id;
|
||||
ops = Array<NetOp*>();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Str_8 NetSys::GetId() const
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
UInt_64 NetSys::GetHashId() const
|
||||
{
|
||||
return hashId;
|
||||
}
|
||||
|
||||
bool NetSys::HasOperation(const UInt_64 hashId) const
|
||||
{
|
||||
for (UInt_64 i = 0; i < ops.Size(); ++i)
|
||||
if (ops[i]->GetHashId() == hashId)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NetSys::AddOperation(NetOp* op)
|
||||
{
|
||||
if (HasOperation(op->GetHashId()))
|
||||
return false;
|
||||
|
||||
ops.Push(op);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void NetSys::Execute(EHC *ehc, NetEnd *endpoint, const UInt_64 hashId, Serializer<UInt_64> &payload)
|
||||
{
|
||||
for (UInt_64 i = 0; i < ops.Size(); ++i)
|
||||
{
|
||||
if (ops[i]->GetHashId() == hashId)
|
||||
{
|
||||
ops[i]->Process(ehc, endpoint, this, payload);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
EHS_LOG_INT(LogType::INFO, 0, "System not found.");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user