diff --git a/Messages/DestroyMsg.cpp b/Messages/DestroyMsg.cpp index 24fbb63..6141582 100644 --- a/Messages/DestroyMsg.cpp +++ b/Messages/DestroyMsg.cpp @@ -12,6 +12,10 @@ DestroyMsg::DestroyMsg(char* buffer) {} DestroyMsg::~DestroyMsg() {} unsigned char DestroyMsg::Serialize(char *buffer) { + #if defined(DEBUG) + std::cout << "Send DestroyMsg [" << (int)this->networkId << "/" << (int)this->thingId + << "] " << std::endl; +#endif unsigned char ix = 0; buffer[ix++] = this->id; buffer[ix++] = this->networkId; diff --git a/Messages/InvestigateMsg.cpp b/Messages/InvestigateMsg.cpp index 7bbde42..6420e42 100644 --- a/Messages/InvestigateMsg.cpp +++ b/Messages/InvestigateMsg.cpp @@ -14,6 +14,10 @@ InvestigateMsg::InvestigateMsg(unsigned char networkId, unsigned char thingId) { InvestigateMsg::~InvestigateMsg() {} unsigned char InvestigateMsg::Serialize(char* buffer) { + #if defined(DEBUG) + std::cout << "Send InvestigateMsg [" << (int)this->networkId << "/" << (int)this->thingId + << "] " << std::endl; +#endif unsigned char ix = 0; buffer[ix++] = this->id; buffer[ix++] = this->networkId; diff --git a/Messages/ModelUrlMsg.cpp b/Messages/ModelUrlMsg.cpp index 5a61165..0753750 100644 --- a/Messages/ModelUrlMsg.cpp +++ b/Messages/ModelUrlMsg.cpp @@ -22,21 +22,23 @@ ModelUrlMsg::ModelUrlMsg(unsigned char networkId, Thing* thing) { else this->urlLength = (unsigned char)strlen(thing->modelUrl); - //this->url = thing->modelUrl; // dangerous! + // this->url = thing->modelUrl; // dangerous! // the url string in the buffer is not \0 terminated! char* url = new char[this->urlLength + 1]; for (int i = 0; i < this->urlLength; i++) url[i] = thing->modelUrl[i]; url[this->urlLength] = '\0'; - this->url = url;} + this->url = url; +} ModelUrlMsg::ModelUrlMsg(const char* buffer) { unsigned char ix = 1; // first byte is msg id this->networkId = buffer[ix++]; this->thingId = buffer[ix++]; this->urlLength = buffer[ix++]; - // this->url = &buffer[ix]; // dangerous! name should not be used anymore after + // this->url = &buffer[ix]; // dangerous! name should not be used anymore + // after // // buffer has been re-used... // the url string in the buffer is not \0 terminated! @@ -54,6 +56,11 @@ ModelUrlMsg::~ModelUrlMsg() { unsigned char ModelUrlMsg::Serialize(char* buffer) { if (this->urlLength == 0 || this->url == nullptr) return 0; +#if defined(DEBUG) + std::cout << "Send ModelUrlMsg [" << (int)this->networkId << "/" + << (int)this->thingId << "] " << (int)this->urlLength << " " + << this->url << std::endl; +#endif unsigned char ix = 0; buffer[ix++] = this->id; buffer[ix++] = this->networkId; diff --git a/Messages/NameMsg.cpp b/Messages/NameMsg.cpp index 36bd474..da91c79 100644 --- a/Messages/NameMsg.cpp +++ b/Messages/NameMsg.cpp @@ -42,6 +42,11 @@ unsigned char NameMsg::Serialize(char* buffer) { if (this->nameLength == 0 || this->name == nullptr) return 0; +#if defined(DEBUG) + std::cout << "Send NameMsg [" << (int)this->networkId << "/" + << (int)this->thingId << "] " << (int)this->nameLength << " " + << this->name << std::endl; +#endif unsigned char ix = 0; buffer[ix++] = this->id; buffer[ix++] = this->networkId; diff --git a/Messages/ParticipantMsg.cpp b/Messages/ParticipantMsg.cpp index 16c3b72..c91fce9 100644 --- a/Messages/ParticipantMsg.cpp +++ b/Messages/ParticipantMsg.cpp @@ -13,13 +13,19 @@ ParticipantMsg::ParticipantMsg(const char* buffer) { ParticipantMsg::~ParticipantMsg() {} unsigned char ParticipantMsg::Serialize(char* buffer) { +#if defined(DEBUG) + std::cout << "Send ParticipantMsg [" << (int)this->networkId << "] " + << std::endl; +#endif + unsigned char ix = 0; buffer[ix++] = this->id; buffer[ix++] = this->networkId; return ParticipantMsg::length; } -// bool ParticipantMsg::Send(ParticipantUDP *participant, unsigned char networkId) { +// bool ParticipantMsg::Send(ParticipantUDP *participant, unsigned char +// networkId) { // ParticipantMsg msg = ParticipantMsg() // } // Client Msg diff --git a/Messages/PoseMsg.cpp b/Messages/PoseMsg.cpp index 4bbb25a..c6d41aa 100644 --- a/Messages/PoseMsg.cpp +++ b/Messages/PoseMsg.cpp @@ -45,6 +45,10 @@ unsigned char PoseMsg::Serialize(char* buffer) { if (this->poseType == 0) return 0; +#if defined(DEBUG) + std::cout << "Send PoseMsg [" << (int)this->networkId << "/" + << (int)this->thingId << "] " << (int)this->poseType << std::endl; +#endif unsigned char ix = 0; buffer[ix++] = PoseMsg::id; buffer[ix++] = this->networkId; diff --git a/Messages/SiteMsg.cpp b/Messages/SiteMsg.cpp index d9f7afd..598a841 100644 --- a/Messages/SiteMsg.cpp +++ b/Messages/SiteMsg.cpp @@ -13,6 +13,9 @@ SiteMsg::SiteMsg(unsigned char networkId) { SiteMsg::~SiteMsg() {} unsigned char SiteMsg::Serialize(char* buffer) { +#if defined(DEBUG) + std::cout << "Send SiteMsg [" << (int)this->networkId << "] " << std::endl; +#endif unsigned char ix = 0; buffer[ix++] = this->id; buffer[ix++] = this->networkId; diff --git a/Messages/TextMsg.cpp b/Messages/TextMsg.cpp index 371bf92..119a907 100644 --- a/Messages/TextMsg.cpp +++ b/Messages/TextMsg.cpp @@ -24,6 +24,9 @@ unsigned char TextMsg::Serialize(char* buffer) { if (this->textLength == 0 || this->text == nullptr) return 0; +#if defined(DEBUG) + std::cout << "Send TextMsg " << (int)this->textLength << " " << this->text << std::endl; +#endif unsigned char ix = 0; buffer[ix++] = this->id; buffer[ix++] = this->textLength;