diff --git a/SiteServer.cpp b/SiteServer.cpp index a1c5dee..83149d0 100644 --- a/SiteServer.cpp +++ b/SiteServer.cpp @@ -2,10 +2,6 @@ #include "Sensors/TemperatureSensor.h" -#include -#include -#include - namespace Passer { namespace Control { @@ -39,24 +35,6 @@ void SiteServer::Process(Participant *sender, ClientMsg *msg) { void SiteServer::Process(Participant *sender, NetworkIdMsg *msg) {} -using ThingConstructor = std::function( - unsigned char networkId, unsigned char thingId)>; -std::unordered_map thingMsgProcessors; - -template -void SiteServer::Register(unsigned char thingType) { - thingMsgProcessors[thingType] = [](unsigned char networkId, - unsigned char thingId) { - return std::make_unique(networkId, thingId); - }; -} - -// template -// void SiteServer::Register(Thing::Type thingType) -// { -// Register((unsigned char)thingType); -// } - void SiteServer::Process(ThingMsg *msg) { Thing *thing = Thing::Get(msg->networkId, msg->thingId); diff --git a/SiteServer.h b/SiteServer.h index 3f38b51..507c8b9 100644 --- a/SiteServer.h +++ b/SiteServer.h @@ -2,6 +2,10 @@ #include "Participant.h" +#include +#include +#include + namespace Passer { namespace Control { @@ -12,8 +16,12 @@ public: virtual void Update(unsigned long currentTimeMs) override; - template void Register(unsigned char thingType); - // template void Register(Thing::Type thingType); + template void Register(unsigned char thingType) { + thingMsgProcessors[thingType] = [](unsigned char networkId, + unsigned char thingId) { + return std::make_unique(networkId, thingId); + }; + }; protected: unsigned long nextPublishMe = 0; @@ -21,6 +29,10 @@ protected: virtual void Process(Participant *sender, ClientMsg *msg) override; virtual void Process(Participant *sender, NetworkIdMsg *msg) override; virtual void Process(ThingMsg *msg) override; + +using ThingConstructor = std::function( + unsigned char networkId, unsigned char thingId)>; + std::unordered_map thingMsgProcessors; }; } // namespace Control