thing name -> source id

This commit is contained in:
Pascal Serrarens 2025-01-26 20:33:12 +01:00
parent 7867c3c8cf
commit a8a09dbebf
3 changed files with 16 additions and 1 deletions

View File

@ -181,6 +181,11 @@ void Participant::ReceiveData(unsigned char bufferSize,
Process(msg);
delete msg;
} break;
case NameMsg::id: {
NameMsg *msg = new NameMsg(this->buffer);
Process(msg);
delete msg;
} break;
case PoseMsg::id: {
PoseMsg *msg = new PoseMsg(this->buffer);
Process(msg);
@ -219,6 +224,15 @@ void Participant::Process(InvestigateMsg *msg) {}
void Participant::Process(ThingMsg *msg) {}
void Participant::Process(NameMsg *msg) {
Thing *thing = Thing::Get(msg->networkId, msg->thingId);
if (thing != nullptr) {
thing->name = new char[strlen(msg->name)];
strcpy(thing->name, msg->name);
std::cout << "thing name = " << thing->name << "\n";
}
}
void Participant::Process(PoseMsg *msg) {}
void Participant::Process(CustomMsg *msg) {

View File

@ -87,6 +87,7 @@ protected:
virtual void Process(Participant *sender, NetworkIdMsg *msg);
virtual void Process(InvestigateMsg *msg);
virtual void Process(ThingMsg *msg);
virtual void Process(NameMsg *msg);
virtual void Process(PoseMsg *msg);
virtual void Process(CustomMsg *msg);
};

View File

@ -73,7 +73,7 @@ protected:
public:
/// @brief The type of Thing
unsigned char type = 0;
const char *name = nullptr;
char *name = nullptr;
const char *modelUrl = nullptr;
float modelScale = 1;
// protected Sensor sensor;