47 lines
1.4 KiB
C++
47 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include "ParticipantUDP.h"
|
|
|
|
#if !defined(NO_STD)
|
|
#include <functional>
|
|
#include <memory>
|
|
#include <unordered_map>
|
|
#endif
|
|
|
|
namespace RoboidControl {
|
|
|
|
/// @brief A participant is device which can communicate with other participants
|
|
class SiteServer : public ParticipantUDP {
|
|
public:
|
|
SiteServer(int port = 7681);
|
|
|
|
// virtual void Update(unsigned long currentTimeMs = 0) override;
|
|
|
|
// #if !defined(NO_STD)
|
|
// template <typename ThingClass>
|
|
// void Register(unsigned char thingType) {
|
|
// thingMsgProcessors[thingType] = [](Participant* participant,
|
|
// unsigned char networkId,
|
|
// unsigned char thingId) {
|
|
// return new ThingClass(participant, networkId, thingId);
|
|
// };
|
|
// };
|
|
// #endif
|
|
|
|
protected:
|
|
unsigned long nextPublishMe = 0;
|
|
|
|
virtual void Process(Participant* sender, ParticipantMsg* msg) override;
|
|
virtual void Process(Participant* sender, SiteMsg* msg) override;
|
|
virtual void Process(Participant* sender, ThingMsg* msg) override;
|
|
|
|
// #if !defined(NO_STD)
|
|
// using ThingConstructor = std::function<Thing*(Participant* participant,
|
|
// unsigned char networkId,
|
|
// unsigned char thingId)>;
|
|
// std::unordered_map<unsigned char, ThingConstructor> thingMsgProcessors;
|
|
// #endif
|
|
};
|
|
|
|
} // namespace RoboidControl
|