diff --git a/Participant.cpp b/Participant.cpp index 25339e2..4fb6c72 100644 --- a/Participant.cpp +++ b/Participant.cpp @@ -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) { diff --git a/Participant.h b/Participant.h index 9e6dc43..5e00490 100644 --- a/Participant.h +++ b/Participant.h @@ -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); }; diff --git a/Thing.h b/Thing.h index 41431c2..b4b29de 100644 --- a/Thing.h +++ b/Thing.h @@ -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;