Roboid Control for C++
Loading...
Searching...
No Matches
d:/Cpp/RoboidControl-cpp/SiteServer.h
1#pragma once
2
3#include "LocalParticipant.h"
4
5#if !defined(NO_STD)
6#include <functional>
7#include <memory>
8#include <unordered_map>
9#endif
10
11namespace RoboidControl {
12
15 public:
16 SiteServer(int port = 7681);
17
18 // virtual void Update(unsigned long currentTimeMs = 0) override;
19
20#if !defined(NO_STD)
21 template <typename ThingClass>
22 void Register(unsigned char thingType) {
23 thingMsgProcessors[thingType] = [](Participant* participant,
24 unsigned char networkId,
25 unsigned char thingId) {
26 return new ThingClass(participant, networkId, thingId);
27 };
28 };
29#endif
30
31 protected:
32 unsigned long nextPublishMe = 0;
33
34 virtual void Process(Participant* sender, ParticipantMsg* msg) override;
35 virtual void Process(Participant* sender, SiteMsg* msg) override;
36 virtual void Process(Participant* sender, ThingMsg* msg) override;
37
38#if !defined(NO_STD)
39 using ThingConstructor = std::function<Thing*(Participant* participant,
40 unsigned char networkId,
41 unsigned char thingId)>;
42 std::unordered_map<unsigned char, ThingConstructor> thingMsgProcessors;
43#endif
44};
45
46} // namespace RoboidControl
A local participant is the local device which can communicate with other participants It manages all ...
Definition LocalParticipant.h:43
A participant is a device which manages things. It can communicate with other participant to synchron...
Definition Participant.h:14
int port
The port number for UDP communication with the participant. This is 0 for isolated participants.
Definition Participant.h:21
unsigned char networkId
The network Id to identify the participant.
Definition Participant.h:25
A participant messages notifies other participants of its presence When received by another participa...
Definition ParticipantMsg.h:10
A message communicating the network ID for that participant.
Definition SiteMsg.h:6
A participant is device which can communicate with other participants.
Definition SiteServer.h:14
A thing is the primitive building block.
Definition Thing.h:20
Message providing generic information about a Thing.
Definition ThingMsg.h:6