Added sendmsg debug messages
This commit is contained in:
parent
122d087f81
commit
1aed9856aa
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user