RemoteParticiapntUDP -> ParticipantSocket

This commit is contained in:
Pascal Serrarens 2025-06-30 08:46:39 +02:00
parent 19a5c5d4d5
commit a826817a0b
14 changed files with 120 additions and 103 deletions

View File

@ -88,7 +88,7 @@ void ParticipantUDP::Receive() {
#endif #endif
} }
bool ParticipantUDP::SendTo(RemoteParticipantUDP* remoteParticipant, int bufferSize) { bool ParticipantUDP::SendTo(ParticipantSocket* remoteParticipant, int bufferSize) {
#if defined(ARDUINO) && defined(HAS_WIFI) #if defined(ARDUINO) && defined(HAS_WIFI)
// std::cout << "Sending to:\n " << remoteParticipant->ipAddress << ":" // std::cout << "Sending to:\n " << remoteParticipant->ipAddress << ":"
// << remoteParticipant->port << "\n"; // << remoteParticipant->port << "\n";

View File

@ -9,7 +9,7 @@ class ParticipantUDP : public ParticipantUDPGeneric {
public: public:
void Setup(); void Setup();
void Receive(); void Receive();
bool SendTo(RemoteParticipantUDP* remoteParticipant, int bufferSize); bool SendTo(ParticipantSocket* remoteParticipant, int bufferSize);
bool Publish(IMessage* msg); bool Publish(IMessage* msg);
protected: protected:

View File

@ -182,7 +182,7 @@ bool ParticipantUDP::Send(IMessage* msg) {
return this->SendTo(this->remoteSite, bufferSize); return this->SendTo(this->remoteSite, bufferSize);
} }
bool ParticipantUDP::SendTo(RemoteParticipantUDP* remoteParticipant, bool ParticipantUDP::SendTo(ParticipantSocket* remoteParticipant,
int bufferSize) { int bufferSize) {
#if defined(IDF_VER) #if defined(IDF_VER)
uint16_t port = ntohs(dest_addr.sin_port); uint16_t port = ntohs(dest_addr.sin_port);

View File

@ -23,7 +23,7 @@ class ParticipantUDP : public ParticipantUDPGeneric {
void Setup(int localPort, const char* remoteIpAddress, int remotePort); void Setup(int localPort, const char* remoteIpAddress, int remotePort);
void Receive(); void Receive();
bool SendTo(RemoteParticipantUDP* remoteParticipant, int bufferSize); bool SendTo(ParticipantSocket* remoteParticipant, int bufferSize);
bool Publish(IMessage* msg); bool Publish(IMessage* msg);
// bool SendTest(); // bool SendTest();

View File

@ -0,0 +1,24 @@
#include "ParticipantSocket.h"
#include <string.h>
namespace RoboidControl {
ParticipantSocket::ParticipantSocket(const char* ipAddress, int port) {
// make a copy of the ip address string
int addressLength = (int)strlen(ipAddress);
int stringLength = addressLength + 1;
char* addressString = new char[stringLength];
#if defined(_WIN32) || defined(_WIN64)
strncpy_s(addressString, stringLength, ipAddress,
addressLength); // Leave space for null terminator
#else
strncpy(addressString, ipAddress, addressLength);
#endif
addressString[addressLength] = '\0';
this->ipAddress = addressString;
this->port = port;
}
}

View File

@ -0,0 +1,28 @@
#pragma once
#include "Participant.h"
namespace RoboidControl {
class ParticipantSocket : public Participant {
public:
/// @brief Create a new participant with the given communcation info
/// @param ipAddress The IP address of the participant
/// @param port The UDP port of the participant
/// @remarks This does not belong here, it should move to ParticipantUDP or
/// something like that in the future
ParticipantSocket(const char* ipAddress, int port);
/// @brief The Ip Address of a participant.
/// @remarks This does not belong here, it should move to ParticipantUDP or
/// something like that in the future
const char* ipAddress = "0.0.0.0";
/// @brief The port number for UDP communication with the participant.
/// @remarks This does not belong here, it should move to ParticipantUDP or
/// something like that in the future
unsigned int port = 0;
bool Send(IMessage* msg) override;
};
}

View File

@ -12,7 +12,7 @@
#include "Things/DistanceSensor.h" #include "Things/DistanceSensor.h"
#include "Things/TouchSensor.h" #include "Things/TouchSensor.h"
#include <string.h> // #include <string.h>
namespace RoboidControl { namespace RoboidControl {
@ -20,10 +20,10 @@ namespace RoboidControl {
ParticipantRegistry ParticipantUDPGeneric::registry; ParticipantRegistry ParticipantUDPGeneric::registry;
RemoteParticipantUDP* ParticipantRegistry::Get(const char* ipAddress, ParticipantSocket* ParticipantRegistry::Get(const char* ipAddress,
unsigned int port) { unsigned int port) {
#if !defined(NO_STD) #if !defined(NO_STD)
for (RemoteParticipantUDP* participant : ParticipantRegistry::participants) { for (ParticipantSocket* participant : ParticipantRegistry::participants) {
if (participant == nullptr) if (participant == nullptr)
continue; continue;
if (strcmp(participant->ipAddress, ipAddress) == 0 && if (strcmp(participant->ipAddress, ipAddress) == 0 &&
@ -39,9 +39,9 @@ RemoteParticipantUDP* ParticipantRegistry::Get(const char* ipAddress,
return nullptr; return nullptr;
} }
RemoteParticipantUDP* ParticipantRegistry::Get(unsigned char participantId) { ParticipantSocket* ParticipantRegistry::Get(unsigned char participantId) {
#if !defined(NO_STD) #if !defined(NO_STD)
for (RemoteParticipantUDP* participant : ParticipantRegistry::participants) { for (ParticipantSocket* participant : ParticipantRegistry::participants) {
if (participant == nullptr) if (participant == nullptr)
continue; continue;
if (participant->networkId == participantId) if (participant->networkId == participantId)
@ -52,14 +52,14 @@ RemoteParticipantUDP* ParticipantRegistry::Get(unsigned char participantId) {
return nullptr; return nullptr;
} }
RemoteParticipantUDP* ParticipantRegistry::Add(const char* ipAddress, ParticipantSocket* ParticipantRegistry::Add(const char* ipAddress,
unsigned int port) { unsigned int port) {
RemoteParticipantUDP* participant = new RemoteParticipantUDP(ipAddress, port); ParticipantSocket* participant = new ParticipantSocket(ipAddress, port);
Add(participant); Add(participant);
return participant; return participant;
} }
void ParticipantRegistry::Add(RemoteParticipantUDP* participant) { void ParticipantRegistry::Add(ParticipantSocket* participant) {
Participant* foundParticipant = Get(participant->networkId); Participant* foundParticipant = Get(participant->networkId);
// Get(participant->ipAddress, participant->port); // Get(participant->ipAddress, participant->port);
@ -84,7 +84,7 @@ void ParticipantRegistry::Add(RemoteParticipantUDP* participant) {
} }
} }
void ParticipantRegistry::Remove(RemoteParticipantUDP* participant) { void ParticipantRegistry::Remove(ParticipantSocket* participant) {
// participants.remove(participant); // participants.remove(participant);
} }
@ -93,31 +93,14 @@ RemoteParticipantUDP** ParticipantRegistry::GetAll() const {
return ParticipantRegistry::participants; return ParticipantRegistry::participants;
} }
#else #else
const std::list<RemoteParticipantUDP*>& ParticipantRegistry::GetAll() const { const std::list<ParticipantSocket*>& ParticipantRegistry::GetAll() const {
return ParticipantRegistry::participants; return ParticipantRegistry::participants;
} }
#endif #endif
#pragma endregion ParticipantRegistry #pragma endregion ParticipantRegistry
RemoteParticipantUDP::RemoteParticipantUDP(const char* ipAddress, int port) { bool ParticipantSocket::Send(IMessage* msg) {
// make a copy of the ip address string
int addressLength = (int)strlen(ipAddress);
int stringLength = addressLength + 1;
char* addressString = new char[stringLength];
#if defined(_WIN32) || defined(_WIN64)
strncpy_s(addressString, stringLength, ipAddress,
addressLength); // Leave space for null terminator
#else
strncpy(addressString, ipAddress, addressLength);
#endif
addressString[addressLength] = '\0';
this->ipAddress = addressString;
this->port = port;
}
bool RemoteParticipantUDP::Send(IMessage* msg) {
// No message is actually sent, because this class has no networking // No message is actually sent, because this class has no networking
// implementation // implementation
return false; return false;
@ -126,7 +109,7 @@ bool RemoteParticipantUDP::Send(IMessage* msg) {
#pragma region Init #pragma region Init
ParticipantUDPGeneric::ParticipantUDPGeneric(int port) ParticipantUDPGeneric::ParticipantUDPGeneric(int port)
: RemoteParticipantUDP("127.0.0.1", port) { : ParticipantSocket("127.0.0.1", port) {
this->name = "ParticipantUDP"; this->name = "ParticipantUDP";
this->remoteSite = nullptr; this->remoteSite = nullptr;
if (this->port == 0) if (this->port == 0)
@ -145,12 +128,12 @@ ParticipantUDPGeneric::ParticipantUDPGeneric(int port)
ParticipantUDPGeneric::ParticipantUDPGeneric(const char* ipAddress, ParticipantUDPGeneric::ParticipantUDPGeneric(const char* ipAddress,
int port, int port,
int localPort) int localPort)
: RemoteParticipantUDP("127.0.0.1", localPort) { : ParticipantSocket("127.0.0.1", localPort) {
this->name = "ParticipantUDP"; this->name = "ParticipantUDP";
if (this->port == 0) if (this->port == 0)
this->isIsolated = true; this->isIsolated = true;
else else
this->remoteSite = new RemoteParticipantUDP(ipAddress, port); this->remoteSite = new ParticipantSocket(ipAddress, port);
registry.Add(this); registry.Add(this);
this->root = Thing::LocalRoot(); // Participant::LocalParticipant->root; this->root = Thing::LocalRoot(); // Participant::LocalParticipant->root;
@ -311,7 +294,7 @@ void ParticipantUDPGeneric::ReceiveData(unsigned char packetSize,
unsigned int senderPort) { unsigned int senderPort) {
// std::cout << "Receive data from " << senderIpAddress << ":" << senderPort // std::cout << "Receive data from " << senderIpAddress << ":" << senderPort
// << std::endl; // << std::endl;
RemoteParticipantUDP* sender = ParticipantSocket* sender =
this->registry.Get(senderIpAddress, senderPort); this->registry.Get(senderIpAddress, senderPort);
if (sender == nullptr) { if (sender == nullptr) {
sender = this->registry.Add(senderIpAddress, senderPort); sender = this->registry.Add(senderIpAddress, senderPort);
@ -325,7 +308,7 @@ void ParticipantUDPGeneric::ReceiveData(unsigned char packetSize,
} }
void ParticipantUDPGeneric::ReceiveData(unsigned char bufferSize, void ParticipantUDPGeneric::ReceiveData(unsigned char bufferSize,
RemoteParticipantUDP* sender) { ParticipantSocket* sender) {
unsigned char msgId = this->buffer[0]; unsigned char msgId = this->buffer[0];
// std::cout << "receive msg " << (int)msgId << "\n"; // std::cout << "receive msg " << (int)msgId << "\n";
// std::cout << " buffer size = " <<(int) bufferSize << "\n"; // std::cout << " buffer size = " <<(int) bufferSize << "\n";
@ -398,7 +381,7 @@ void ParticipantUDPGeneric::ReceiveData(unsigned char bufferSize,
#endif #endif
} }
void ParticipantUDPGeneric::Process(RemoteParticipantUDP* sender, void ParticipantUDPGeneric::Process(ParticipantSocket* sender,
ParticipantMsg* msg) { ParticipantMsg* msg) {
#if defined(DEBUG) #if defined(DEBUG)
std::cout << this->name << ": Process ParticipantMsg " << (int)msg->networkId std::cout << this->name << ": Process ParticipantMsg " << (int)msg->networkId
@ -406,7 +389,7 @@ void ParticipantUDPGeneric::Process(RemoteParticipantUDP* sender,
#endif #endif
} }
void ParticipantUDPGeneric::Process(RemoteParticipantUDP* sender, void ParticipantUDPGeneric::Process(ParticipantSocket* sender,
NetworkIdMsg* msg) { NetworkIdMsg* msg) {
#if defined(DEBUG) #if defined(DEBUG)
std::cout << this->name << ": process NetworkIdMsg " << (int)this->networkId std::cout << this->name << ": process NetworkIdMsg " << (int)this->networkId
@ -422,7 +405,7 @@ void ParticipantUDPGeneric::Process(RemoteParticipantUDP* sender,
} }
} }
void ParticipantUDPGeneric::Process(RemoteParticipantUDP* sender, void ParticipantUDPGeneric::Process(ParticipantSocket* sender,
InvestigateMsg* msg) { InvestigateMsg* msg) {
#if defined(DEBUG) #if defined(DEBUG)
std::cout << this->name << ": Process InvestigateMsg [" << (int)msg->networkId std::cout << this->name << ": Process InvestigateMsg [" << (int)msg->networkId
@ -430,16 +413,16 @@ void ParticipantUDPGeneric::Process(RemoteParticipantUDP* sender,
#endif #endif
} }
void ParticipantUDPGeneric::Process(RemoteParticipantUDP* sender, void ParticipantUDPGeneric::Process(ParticipantSocket* sender,
ThingMsg* msg) { ThingMsg* msg) {
#if defined(DEBUG) #if defined(DEBUG)
std::cout << this->name << ": process ThingMsg [" << (int)msg->networkId std::cout << this->name << ": process ThingMsg [" << (int)msg->networkId
<< "/" << (int)msg->thingId << "] " << (int)msg->thingType << " " << "/" << (int)msg->thingId << "] " << (int)msg->thingType << " "
<< (int)msg->parentId << "\n"; << (int)msg->parentId << "\n";
#endif #endif
RemoteParticipantUDP* owner = registry.Get(msg->networkId); ParticipantSocket* owner = registry.Get(msg->networkId);
if (owner == nullptr) { if (owner == nullptr) {
owner = new RemoteParticipantUDP(sender->ipAddress, sender->port); owner = new ParticipantSocket(sender->ipAddress, sender->port);
owner->networkId = msg->networkId; owner->networkId = msg->networkId;
registry.Add(owner); registry.Add(owner);
} }
@ -461,7 +444,7 @@ void ParticipantUDPGeneric::Process(RemoteParticipantUDP* sender,
thing->SetParent(nullptr); thing->SetParent(nullptr);
} }
Thing* ParticipantUDPGeneric::ProcessNewThing(RemoteParticipantUDP* owner, Thing* ParticipantUDPGeneric::ProcessNewThing(ParticipantSocket* owner,
ThingMsg* msg, ThingMsg* msg,
bool isRemote) { bool isRemote) {
switch (msg->thingType) { switch (msg->thingType) {
@ -476,7 +459,7 @@ Thing* ParticipantUDPGeneric::ProcessNewThing(RemoteParticipantUDP* owner,
} }
} }
void ParticipantUDPGeneric::Process(RemoteParticipantUDP* sender, void ParticipantUDPGeneric::Process(ParticipantSocket* sender,
NameMsg* msg) { NameMsg* msg) {
#if defined(DEBUG) #if defined(DEBUG)
std::cout << this->name << ": process NameMsg [" << (int)msg->networkId << "/" std::cout << this->name << ": process NameMsg [" << (int)msg->networkId << "/"
@ -509,7 +492,7 @@ void ParticipantUDPGeneric::Process(RemoteParticipantUDP* sender,
#endif #endif
} }
void ParticipantUDPGeneric::Process(RemoteParticipantUDP* sender, void ParticipantUDPGeneric::Process(ParticipantSocket* sender,
ModelUrlMsg* msg) { ModelUrlMsg* msg) {
#if defined(DEBUG) #if defined(DEBUG)
std::cout << this->name << ": process ModelUrlMsg [" << (int)msg->networkId std::cout << this->name << ": process ModelUrlMsg [" << (int)msg->networkId
@ -517,7 +500,7 @@ void ParticipantUDPGeneric::Process(RemoteParticipantUDP* sender,
#endif #endif
} }
void ParticipantUDPGeneric::Process(RemoteParticipantUDP* sender, void ParticipantUDPGeneric::Process(ParticipantSocket* sender,
PoseMsg* msg) { PoseMsg* msg) {
#if !defined(DEBUG) && !defined(NO_STD) #if !defined(DEBUG) && !defined(NO_STD)
std::cout << this->name << ": process PoseMsg [" << (int)this->networkId std::cout << this->name << ": process PoseMsg [" << (int)this->networkId
@ -541,7 +524,7 @@ void ParticipantUDPGeneric::Process(RemoteParticipantUDP* sender,
thing->SetAngularVelocity(msg->angularVelocity); thing->SetAngularVelocity(msg->angularVelocity);
} }
void ParticipantUDPGeneric::Process(RemoteParticipantUDP* sender, void ParticipantUDPGeneric::Process(ParticipantSocket* sender,
BinaryMsg* msg) { BinaryMsg* msg) {
#if defined(DEBUG) #if defined(DEBUG)
std::cout << this->name << ": process BinaryMsg [" << (int)msg->networkId std::cout << this->name << ": process BinaryMsg [" << (int)msg->networkId
@ -564,7 +547,7 @@ void ParticipantUDPGeneric::Process(RemoteParticipantUDP* sender,
} }
} }
void ParticipantUDPGeneric::Process(RemoteParticipantUDP* sender, void ParticipantUDPGeneric::Process(ParticipantSocket* sender,
TextMsg* msg) { TextMsg* msg) {
#if defined(DEBUG) #if defined(DEBUG)
std::cout << this->name << ": process TextMsg " << (int)msg->textLength << " " std::cout << this->name << ": process TextMsg " << (int)msg->textLength << " "
@ -572,7 +555,7 @@ void ParticipantUDPGeneric::Process(RemoteParticipantUDP* sender,
#endif #endif
} }
void ParticipantUDPGeneric::Process(RemoteParticipantUDP* sender, void ParticipantUDPGeneric::Process(ParticipantSocket* sender,
DestroyMsg* msg) { DestroyMsg* msg) {
#if defined(DEBUG) #if defined(DEBUG)
std::cout << this->name << ": process Destroy [" << (int)msg->networkId << "/" std::cout << this->name << ": process Destroy [" << (int)msg->networkId << "/"

View File

@ -10,7 +10,8 @@
#include "Messages/PoseMsg.h" #include "Messages/PoseMsg.h"
#include "Messages/TextMsg.h" #include "Messages/TextMsg.h"
#include "Messages/ThingMsg.h" #include "Messages/ThingMsg.h"
#include "Participant.h"
#include "ParticipantSocket.h"
#if !defined(NO_STD) #if !defined(NO_STD)
#include <functional> #include <functional>
@ -31,26 +32,7 @@ namespace RoboidControl {
constexpr int MAX_SENDER_COUNT = 256; constexpr int MAX_SENDER_COUNT = 256;
class RemoteParticipantUDP : public Participant {
public:
/// @brief Create a new participant with the given communcation info
/// @param ipAddress The IP address of the participant
/// @param port The UDP port of the participant
/// @remarks This does not belong here, it should move to ParticipantUDP or
/// something like that in the future
RemoteParticipantUDP(const char* ipAddress, int port);
/// @brief The Ip Address of a participant.
/// @remarks This does not belong here, it should move to ParticipantUDP or
/// something like that in the future
const char* ipAddress = "0.0.0.0";
/// @brief The port number for UDP communication with the participant.
/// @remarks This does not belong here, it should move to ParticipantUDP or
/// something like that in the future
unsigned int port = 0;
bool Send(IMessage* msg) override;
};
/// @brief class which manages all known participants /// @brief class which manages all known participants
class ParticipantRegistry { class ParticipantRegistry {
@ -59,43 +41,43 @@ class ParticipantRegistry {
/// @param ipAddress The IP address of the participant /// @param ipAddress The IP address of the participant
/// @param port The port number of the participant /// @param port The port number of the participant
/// @return The participant or a nullptr when it could not be found /// @return The participant or a nullptr when it could not be found
RemoteParticipantUDP* Get(const char* ipAddress, unsigned int port); ParticipantSocket* Get(const char* ipAddress, unsigned int port);
/// @brief Retrieve a participant by its network ID /// @brief Retrieve a participant by its network ID
/// @param networkID The network ID of the participant /// @param networkID The network ID of the participant
/// @return The participant or a nullptr when it could not be found /// @return The participant or a nullptr when it could not be found
RemoteParticipantUDP* Get(unsigned char networkID); ParticipantSocket* Get(unsigned char networkID);
/// @brief Add a participant with the given details /// @brief Add a participant with the given details
/// @param ipAddress The IP address of the participant /// @param ipAddress The IP address of the participant
/// @param port The port number of the participant /// @param port The port number of the participant
/// @return The added participant /// @return The added participant
RemoteParticipantUDP* Add(const char* ipAddress, unsigned int port); ParticipantSocket* Add(const char* ipAddress, unsigned int port);
/// @brief Add a participant /// @brief Add a participant
/// @param participant The participant to add /// @param participant The participant to add
void Add(RemoteParticipantUDP* participant); void Add(ParticipantSocket* participant);
/// @brief Remove a participant /// @brief Remove a participant
/// @param participant The participant to remove /// @param participant The participant to remove
void Remove(RemoteParticipantUDP* participant); void Remove(ParticipantSocket* participant);
private: private:
#if defined(NO_STD) #if defined(NO_STD)
public: public:
RemoteParticipantUDP** GetAll() const; ParticipantSocket** GetAll() const;
int count = 0; int count = 0;
private: private:
RemoteParticipantUDP** participants; ParticipantSocket** participants;
#else #else
public: public:
/// @brief Get all participants /// @brief Get all participants
/// @return All participants /// @return All participants
const std::list<RemoteParticipantUDP*>& GetAll() const; const std::list<ParticipantSocket*>& GetAll() const;
private: private:
/// @brief The list of known participants /// @brief The list of known participants
std::list<RemoteParticipantUDP*> participants; std::list<ParticipantSocket*> participants;
#endif #endif
}; };
@ -111,7 +93,7 @@ class ParticipantRegistry {
/// participant is created which can be obtained using /// participant is created which can be obtained using
/// RoboidControl::IsolatedParticipant::Isolated(). /// RoboidControl::IsolatedParticipant::Isolated().
/// @sa RoboidControl::Thing::Thing() /// @sa RoboidControl::Thing::Thing()
class ParticipantUDPGeneric : public RemoteParticipantUDP { class ParticipantUDPGeneric : public ParticipantSocket {
#pragma region Init #pragma region Init
public: public:
@ -139,7 +121,7 @@ class ParticipantUDPGeneric : public RemoteParticipantUDP {
bool isIsolated = false; bool isIsolated = false;
/// @brief The remote site when this participant is connected to a site /// @brief The remote site when this participant is connected to a site
RemoteParticipantUDP* remoteSite = nullptr; ParticipantSocket* remoteSite = nullptr;
/// The interval in milliseconds for publishing (broadcasting) data on the /// The interval in milliseconds for publishing (broadcasting) data on the
/// local network /// local network
@ -192,27 +174,27 @@ class ParticipantUDPGeneric : public RemoteParticipantUDP {
void ReceiveData(unsigned char bufferSize, void ReceiveData(unsigned char bufferSize,
char* senderIpAddress, char* senderIpAddress,
unsigned int senderPort); unsigned int senderPort);
void ReceiveData(unsigned char bufferSize, RemoteParticipantUDP* remoteParticipant); void ReceiveData(unsigned char bufferSize, ParticipantSocket* remoteParticipant);
virtual void SetupUDP(int localPort, const char* remoteIpAddress, int remotePort) = 0; virtual void SetupUDP(int localPort, const char* remoteIpAddress, int remotePort) = 0;
virtual void ReceiveUDP() = 0; virtual void ReceiveUDP() = 0;
virtual void Process(RemoteParticipantUDP* sender, ParticipantMsg* msg); virtual void Process(ParticipantSocket* sender, ParticipantMsg* msg);
virtual void Process(RemoteParticipantUDP* sender, NetworkIdMsg* msg); virtual void Process(ParticipantSocket* sender, NetworkIdMsg* msg);
virtual void Process(RemoteParticipantUDP* sender, InvestigateMsg* msg); virtual void Process(ParticipantSocket* sender, InvestigateMsg* msg);
virtual void Process(RemoteParticipantUDP* sender, ThingMsg* msg); virtual void Process(ParticipantSocket* sender, ThingMsg* msg);
virtual Thing* ProcessNewThing(RemoteParticipantUDP* sender, virtual Thing* ProcessNewThing(ParticipantSocket* sender,
ThingMsg* msg, ThingMsg* msg,
bool isRemote); bool isRemote);
virtual void Process(RemoteParticipantUDP* sender, NameMsg* msg); virtual void Process(ParticipantSocket* sender, NameMsg* msg);
virtual void Process(RemoteParticipantUDP* sender, ModelUrlMsg* msg); virtual void Process(ParticipantSocket* sender, ModelUrlMsg* msg);
virtual void Process(RemoteParticipantUDP* sender, PoseMsg* msg); virtual void Process(ParticipantSocket* sender, PoseMsg* msg);
virtual void Process(RemoteParticipantUDP* sender, BinaryMsg* msg); virtual void Process(ParticipantSocket* sender, BinaryMsg* msg);
virtual void Process(RemoteParticipantUDP* sender, TextMsg* msg); virtual void Process(ParticipantSocket* sender, TextMsg* msg);
virtual void Process(RemoteParticipantUDP* sender, DestroyMsg* msg); virtual void Process(ParticipantSocket* sender, DestroyMsg* msg);
#pragma endregion Receive #pragma endregion Receive

View File

@ -56,7 +56,7 @@ void SiteServer::UpdateMyThings() {
#pragma region Receive #pragma region Receive
void SiteServer::Process(RemoteParticipantUDP* sender, ParticipantMsg* msg) { void SiteServer::Process(ParticipantSocket* sender, ParticipantMsg* msg) {
if (msg->networkId != sender->networkId) { if (msg->networkId != sender->networkId) {
// std::cout << this->name << " received New Client -> " << // std::cout << this->name << " received New Client -> " <<
// sender->ipAddress // sender->ipAddress
@ -67,9 +67,9 @@ void SiteServer::Process(RemoteParticipantUDP* sender, ParticipantMsg* msg) {
} }
} }
void SiteServer::Process(RemoteParticipantUDP* sender, NetworkIdMsg* msg) {} void SiteServer::Process(ParticipantSocket* sender, NetworkIdMsg* msg) {}
void SiteServer::Process(RemoteParticipantUDP* sender, ThingMsg* msg) { void SiteServer::Process(ParticipantSocket* sender, ThingMsg* msg) {
Thing* thing = sender->Get(msg->networkId, msg->thingId); Thing* thing = sender->Get(msg->networkId, msg->thingId);
if (thing == nullptr) { if (thing == nullptr) {
// new Thing(sender, (Thing::Type)msg->thingType, msg->thingId); // new Thing(sender, (Thing::Type)msg->thingType, msg->thingId);

View File

@ -33,9 +33,9 @@ class SiteServer : public ParticipantUDPGeneric {
protected: protected:
unsigned long nextPublishMe = 0; unsigned long nextPublishMe = 0;
virtual void Process(RemoteParticipantUDP* sender, ParticipantMsg* msg) override; virtual void Process(ParticipantSocket* sender, ParticipantMsg* msg) override;
virtual void Process(RemoteParticipantUDP* sender, NetworkIdMsg* msg) override; virtual void Process(ParticipantSocket* sender, NetworkIdMsg* msg) override;
virtual void Process(RemoteParticipantUDP* sender, ThingMsg* msg) override; virtual void Process(ParticipantSocket* sender, ThingMsg* msg) override;
#pragma endregion Receive #pragma endregion Receive

View File

@ -90,7 +90,7 @@ void ParticipantUDP::Receive() {
#endif #endif
} }
bool ParticipantUDP::SendTo(RemoteParticipantUDP* remoteParticipant, int bufferSize) { bool ParticipantUDP::SendTo(ParticipantSocket* remoteParticipant, int bufferSize) {
#if defined(__unix__) || defined(__APPLE__) #if defined(__unix__) || defined(__APPLE__)
// std::cout << "Send to " << remoteParticipant->ipAddress << ":" << ntohs(remoteParticipant->port) // std::cout << "Send to " << remoteParticipant->ipAddress << ":" << ntohs(remoteParticipant->port)
// << "\n"; // << "\n";

View File

@ -9,7 +9,7 @@ class ParticipantUDP : public ParticipantUDPGeneric {
public: public:
void Setup(int localPort, const char* remoteIpAddress, int remotePort); void Setup(int localPort, const char* remoteIpAddress, int remotePort);
void Receive(); void Receive();
bool SendTo(RemoteParticipantUDP* remoteParticipant, int bufferSize); bool SendTo(ParticipantSocket* remoteParticipant, int bufferSize);
bool Publish(IMessage* msg); bool Publish(IMessage* msg);
protected: protected:

View File

@ -102,7 +102,7 @@ void ParticipantUDP::Receive() {
#endif // _WIN32 || _WIN64 #endif // _WIN32 || _WIN64
} }
bool ParticipantUDP::SendTo(RemoteParticipantUDP* remoteParticipant, int bufferSize) { bool ParticipantUDP::SendTo(ParticipantSocket* remoteParticipant, int bufferSize) {
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
char ip_str[INET_ADDRSTRLEN]; char ip_str[INET_ADDRSTRLEN];
inet_ntop(AF_INET, &(remote_addr.sin_addr), ip_str, INET_ADDRSTRLEN); inet_ntop(AF_INET, &(remote_addr.sin_addr), ip_str, INET_ADDRSTRLEN);

View File

@ -9,7 +9,7 @@ class ParticipantUDP : public ParticipantUDPGeneric {
public: public:
void Setup(int localPort, const char* remoteIpAddress, int remotePort); void Setup(int localPort, const char* remoteIpAddress, int remotePort);
void Receive(); void Receive();
bool SendTo(RemoteParticipantUDP* remoteParticipant, int bufferSize); bool SendTo(ParticipantSocket* remoteParticipant, int bufferSize);
bool Publish(IMessage* msg); bool Publish(IMessage* msg);
protected: protected: