Compare commits

..

No commits in common. "fe021e3b8aa65e545d97075110c5804decc0f1bc" and "5bce1b7d2a7a58d2f29c3836be7a2c281aaabc4c" have entirely different histories.

8 changed files with 4 additions and 40 deletions

View File

@ -12,10 +12,6 @@ DestroyMsg::DestroyMsg(char* buffer) {}
DestroyMsg::~DestroyMsg() {} DestroyMsg::~DestroyMsg() {}
unsigned char DestroyMsg::Serialize(char *buffer) { 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; unsigned char ix = 0;
buffer[ix++] = this->id; buffer[ix++] = this->id;
buffer[ix++] = this->networkId; buffer[ix++] = this->networkId;

View File

@ -14,10 +14,6 @@ InvestigateMsg::InvestigateMsg(unsigned char networkId, unsigned char thingId) {
InvestigateMsg::~InvestigateMsg() {} InvestigateMsg::~InvestigateMsg() {}
unsigned char InvestigateMsg::Serialize(char* buffer) { 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; unsigned char ix = 0;
buffer[ix++] = this->id; buffer[ix++] = this->id;
buffer[ix++] = this->networkId; buffer[ix++] = this->networkId;

View File

@ -22,23 +22,21 @@ ModelUrlMsg::ModelUrlMsg(unsigned char networkId, Thing* thing) {
else else
this->urlLength = (unsigned char)strlen(thing->modelUrl); 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! // the url string in the buffer is not \0 terminated!
char* url = new char[this->urlLength + 1]; char* url = new char[this->urlLength + 1];
for (int i = 0; i < this->urlLength; i++) for (int i = 0; i < this->urlLength; i++)
url[i] = thing->modelUrl[i]; url[i] = thing->modelUrl[i];
url[this->urlLength] = '\0'; url[this->urlLength] = '\0';
this->url = url; this->url = url;}
}
ModelUrlMsg::ModelUrlMsg(const char* buffer) { ModelUrlMsg::ModelUrlMsg(const char* buffer) {
unsigned char ix = 1; // first byte is msg id unsigned char ix = 1; // first byte is msg id
this->networkId = buffer[ix++]; this->networkId = buffer[ix++];
this->thingId = buffer[ix++]; this->thingId = buffer[ix++];
this->urlLength = buffer[ix++]; this->urlLength = buffer[ix++];
// this->url = &buffer[ix]; // dangerous! name should not be used anymore // this->url = &buffer[ix]; // dangerous! name should not be used anymore after
// after
// // buffer has been re-used... // // buffer has been re-used...
// the url string in the buffer is not \0 terminated! // the url string in the buffer is not \0 terminated!
@ -56,11 +54,6 @@ ModelUrlMsg::~ModelUrlMsg() {
unsigned char ModelUrlMsg::Serialize(char* buffer) { unsigned char ModelUrlMsg::Serialize(char* buffer) {
if (this->urlLength == 0 || this->url == nullptr) if (this->urlLength == 0 || this->url == nullptr)
return 0; 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; unsigned char ix = 0;
buffer[ix++] = this->id; buffer[ix++] = this->id;
buffer[ix++] = this->networkId; buffer[ix++] = this->networkId;

View File

@ -42,11 +42,6 @@ unsigned char NameMsg::Serialize(char* buffer) {
if (this->nameLength == 0 || this->name == nullptr) if (this->nameLength == 0 || this->name == nullptr)
return 0; 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; unsigned char ix = 0;
buffer[ix++] = this->id; buffer[ix++] = this->id;
buffer[ix++] = this->networkId; buffer[ix++] = this->networkId;

View File

@ -13,19 +13,13 @@ ParticipantMsg::ParticipantMsg(const char* buffer) {
ParticipantMsg::~ParticipantMsg() {} ParticipantMsg::~ParticipantMsg() {}
unsigned char ParticipantMsg::Serialize(char* buffer) { unsigned char ParticipantMsg::Serialize(char* buffer) {
#if defined(DEBUG)
std::cout << "Send ParticipantMsg [" << (int)this->networkId << "] "
<< std::endl;
#endif
unsigned char ix = 0; unsigned char ix = 0;
buffer[ix++] = this->id; buffer[ix++] = this->id;
buffer[ix++] = this->networkId; buffer[ix++] = this->networkId;
return ParticipantMsg::length; return ParticipantMsg::length;
} }
// bool ParticipantMsg::Send(ParticipantUDP *participant, unsigned char // bool ParticipantMsg::Send(ParticipantUDP *participant, unsigned char networkId) {
// networkId) {
// ParticipantMsg msg = ParticipantMsg() // ParticipantMsg msg = ParticipantMsg()
// } // }
// Client Msg // Client Msg

View File

@ -45,10 +45,6 @@ unsigned char PoseMsg::Serialize(char* buffer) {
if (this->poseType == 0) if (this->poseType == 0)
return 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; unsigned char ix = 0;
buffer[ix++] = PoseMsg::id; buffer[ix++] = PoseMsg::id;
buffer[ix++] = this->networkId; buffer[ix++] = this->networkId;

View File

@ -13,9 +13,6 @@ SiteMsg::SiteMsg(unsigned char networkId) {
SiteMsg::~SiteMsg() {} SiteMsg::~SiteMsg() {}
unsigned char SiteMsg::Serialize(char* buffer) { unsigned char SiteMsg::Serialize(char* buffer) {
#if defined(DEBUG)
std::cout << "Send SiteMsg [" << (int)this->networkId << "] " << std::endl;
#endif
unsigned char ix = 0; unsigned char ix = 0;
buffer[ix++] = this->id; buffer[ix++] = this->id;
buffer[ix++] = this->networkId; buffer[ix++] = this->networkId;

View File

@ -24,9 +24,6 @@ unsigned char TextMsg::Serialize(char* buffer) {
if (this->textLength == 0 || this->text == nullptr) if (this->textLength == 0 || this->text == nullptr)
return 0; return 0;
#if defined(DEBUG)
std::cout << "Send TextMsg " << (int)this->textLength << " " << this->text << std::endl;
#endif
unsigned char ix = 0; unsigned char ix = 0;
buffer[ix++] = this->id; buffer[ix++] = this->id;
buffer[ix++] = this->textLength; buffer[ix++] = this->textLength;