Basic things seems to work, now start doing the tracker stuff

This commit is contained in:
Pascal Serrarens 2025-04-03 12:54:40 +02:00
parent afc48a1438
commit 7b17d8459a
2 changed files with 13 additions and 11 deletions

View File

@ -102,7 +102,6 @@ void LocalParticipant::Receive() {
char sender_ipAddress[16];
inet_ntoa_r(this->src_addr.sin_addr, sender_ipAddress, INET_ADDRSTRLEN);
unsigned int sender_port = ntohs(this->src_addr.sin_port);
std::cout << "Received from " << ntohs(this->src_addr.sin_port) << "\n";
ReceiveData(packetSize, sender_ipAddress, sender_port);

View File

@ -25,8 +25,6 @@
namespace RoboidControl {
// LocalParticipant::LocalParticipant() {}
LocalParticipant::LocalParticipant(int port) {
this->ipAddress = "0.0.0.0";
this->port = port;
@ -260,8 +258,8 @@ void LocalParticipant::ReceiveData(unsigned char packetSize,
this->GetParticipant(senderIpAddress, senderPort);
if (remoteParticipant == nullptr) {
remoteParticipant = this->AddParticipant(senderIpAddress, senderPort);
std::cout << "New sender " << senderIpAddress << ":" << senderPort
<< "\n";
// std::cout << "New sender " << senderIpAddress << ":" << senderPort
// << "\n";
std::cout << "New remote participant " << remoteParticipant->ipAddress
<< ":" << remoteParticipant->port << " "
<< (int)remoteParticipant->networkId << "\n";
@ -273,7 +271,7 @@ void LocalParticipant::ReceiveData(unsigned char packetSize,
void LocalParticipant::ReceiveData(unsigned char bufferSize,
Participant* remoteParticipant) {
unsigned char msgId = this->buffer[0];
// std::cout << "receive msg " << (int)msgId << "\n";
//std::cout << "receive msg " << (int)msgId << "\n";
switch (msgId) {
case ParticipantMsg::id: {
ParticipantMsg* msg = new ParticipantMsg(this->buffer);
@ -328,9 +326,14 @@ void LocalParticipant::Process(Participant* sender, SiteMsg* msg) {
void LocalParticipant::Process(Participant* sender, InvestigateMsg* msg) {}
void LocalParticipant::Process(Participant* sender, ThingMsg* msg) {}
void LocalParticipant::Process(Participant* sender, ThingMsg* msg) {
std::cout << this->name << ": process Thing [" << (int)this->networkId << "/" << (int)msg->networkId << "]\n";
}
void LocalParticipant::Process(Participant* sender, NameMsg* msg) {
std::cout << this->name << ": process Name [" << (int)this->networkId
<< "/" << (int)msg->networkId << "]\n";
Thing* thing = sender->Get(msg->networkId, msg->thingId);
if (thing != nullptr) {
int nameLength = msg->nameLength;
@ -353,12 +356,12 @@ void LocalParticipant::Process(Participant* sender, NameMsg* msg) {
}
}
void LocalParticipant::Process(Participant* sender, PoseMsg* msg) {}
void LocalParticipant::Process(Participant* sender, PoseMsg* msg) {
std::cout << this->name << ": process Pose [" << (int)this->networkId << "/" << (int)msg->networkId << "]\n";
}
void LocalParticipant::Process(Participant* sender, BinaryMsg* msg) {
// std::cout << this->name << ": process Binary [" << (int)this->networkId <<
// "/"
// << (int)msg->networkId << "]\n";
std::cout << this->name << ": process Binary [" << (int)this->networkId << "/" << (int)msg->networkId << "]\n";
Thing* thing = sender->Get(msg->networkId, msg->thingId);
if (thing != nullptr)
thing->ProcessBinary(msg->bytes);