#include "SiteServer.h" #include "Sensors/TemperatureSensor.h" #include #include namespace RoboidControl { SiteServer::SiteServer(int port) { this->name = "Site Server"; this->publishInterval = 0; this->ipAddress = "0.0.0.0"; this->port = port; this->senders.push_back(this); SetupUDP(port, ipAddress, 0); Register((unsigned char)Thing::Type::TemperatureSensor); } void SiteServer::Process(Participant *sender, ParticipantMsg *msg) { if (msg->networkId == 0) { std::cout << this->name << " received New Client -> " << sender->ipAddress << ":" << (int)sender->port << "\n"; SiteMsg *msg = new SiteMsg(sender->networkId); this->Send(sender, msg); delete msg; } } void SiteServer::Process(Participant *sender, SiteMsg *msg) {} void SiteServer::Process(Participant *sender, ThingMsg *msg) { Thing *thing = sender->Get(msg->networkId, msg->thingId); if (thing == nullptr) { auto thingMsgProcessor = thingMsgProcessors.find(msg->thingType); Thing *newThing; if (thingMsgProcessor != thingMsgProcessors.end()) // found item newThing = thingMsgProcessor->second(sender, msg->networkId, msg->thingId); else newThing = new Thing(sender, msg->networkId, msg->thingId, (Thing::Type)msg->thingType); //sender->Add(newThing); } } } // namespace Control