Roboid Control for C++
Loading...
Searching...
No Matches
d:/C/controlcore_cpp/SiteServer.h
1#pragma once
2
3#include "Participant.h"
4
5#include <functional>
6#include <memory>
7#include <unordered_map>
8
9namespace Passer {
10namespace RoboidControl {
11
13class SiteServer : public Participant {
14public:
15 SiteServer(int port = 7681);
16
17 // virtual void Update(unsigned long currentTimeMs = 0) override;
18
19 template <typename ThingClass> void Register(unsigned char thingType) {
20 thingMsgProcessors[thingType] = [](unsigned char networkId,
21 unsigned char thingId) {
22 return new ThingClass(networkId, thingId);
23 };
24 };
25
26protected:
27 unsigned long nextPublishMe = 0;
28
29 virtual void Process(RemoteParticipant *sender, ParticipantMsg *msg) override;
30 virtual void Process(RemoteParticipant *sender, NetworkIdMsg *msg) override;
31 virtual void Process(RemoteParticipant* sender, ThingMsg *msg) override;
32
33 using ThingConstructor =
34 std::function<Thing *(unsigned char networkId, unsigned char thingId)>;
35 std::unordered_map<unsigned char, ThingConstructor> thingMsgProcessors;
36};
37
38} // namespace Control
39} // namespace Passer
40using namespace Passer::RoboidControl;
A message communicating the network ID for that participant.
Definition NetworkIdMsg.h:7
A participant is device which can communicate with other participants.
Definition Participant.h:31
A participant messages notifies other participants of its presence When received by another participa...
Definition ParticipantMsg.h:11
A reference to a participant, possibly on a remote location.
Definition RemoteParticipant.h:8
unsigned char networkId
The network ID of the participant.
Definition RemoteParticipant.h:16
int port
The UDP port on which the participant can be reached.
Definition RemoteParticipant.h:13
A participant is device which can communicate with other participants.
Definition SiteServer.h:13
A thing is the primitive building block.
Definition Thing.h:17
Message providing generic information about a Thing.
Definition ThingMsg.h:7