Cleanup
This commit is contained in:
parent
b027460c63
commit
788765dc97
@ -8,17 +8,8 @@
|
|||||||
|
|
||||||
IMessage::IMessage() {}
|
IMessage::IMessage() {}
|
||||||
|
|
||||||
// IMessage::IMessage(unsigned char *buffer) { Deserialize(buffer); }
|
|
||||||
|
|
||||||
unsigned char IMessage::Serialize(unsigned char *buffer) { return 0; }
|
unsigned char IMessage::Serialize(unsigned char *buffer) { return 0; }
|
||||||
|
|
||||||
// void IMessage::Deserialize(unsigned char *buffer) {}
|
|
||||||
|
|
||||||
// bool IMessage::SendMsg(Participant *client, IMessage msg) {
|
|
||||||
// // return SendMsg(client, client.buffer, );nameLength
|
|
||||||
// return client->SendBuffer(msg.Serialize(client->buffer));
|
|
||||||
// }
|
|
||||||
|
|
||||||
unsigned char *IMessage::ReceiveMsg(unsigned char packetSize) {
|
unsigned char *IMessage::ReceiveMsg(unsigned char packetSize) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -39,14 +30,11 @@ ClientMsg::ClientMsg(unsigned char networkId) { this->networkId = networkId; }
|
|||||||
|
|
||||||
unsigned char ClientMsg::Serialize(unsigned char *buffer) {
|
unsigned char ClientMsg::Serialize(unsigned char *buffer) {
|
||||||
unsigned char ix = 0;
|
unsigned char ix = 0;
|
||||||
buffer[ix++] = this->id;
|
buffer[ix++] = ClientMsg::id;
|
||||||
buffer[ix++] = this->networkId;
|
buffer[ix++] = this->networkId;
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
||||||
// bool ClientMsg::Send(Participant *participant, unsigned char networkId) {
|
|
||||||
// ClientMsg msg = ClientMsg()
|
|
||||||
// }
|
|
||||||
// Client Msg
|
// Client Msg
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
@ -56,10 +44,6 @@ NetworkIdMsg::NetworkIdMsg(unsigned char *buffer) {
|
|||||||
this->networkId = buffer[1];
|
this->networkId = buffer[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// void NetworkIdMsg::Deserialize(unsigned char *buffer) {
|
|
||||||
// this->networkId = buffer[1];
|
|
||||||
// }
|
|
||||||
|
|
||||||
NetworkIdMsg NetworkIdMsg::Receive(unsigned char *buffer,
|
NetworkIdMsg NetworkIdMsg::Receive(unsigned char *buffer,
|
||||||
unsigned char bufferSize) {
|
unsigned char bufferSize) {
|
||||||
NetworkIdMsg msg = NetworkIdMsg(buffer);
|
NetworkIdMsg msg = NetworkIdMsg(buffer);
|
||||||
@ -83,18 +67,12 @@ InvestigateMsg::InvestigateMsg(unsigned char networkId, unsigned char thingId) {
|
|||||||
|
|
||||||
unsigned char InvestigateMsg::Serialize(unsigned char *buffer) {
|
unsigned char InvestigateMsg::Serialize(unsigned char *buffer) {
|
||||||
unsigned char ix = 0;
|
unsigned char ix = 0;
|
||||||
buffer[ix++] = this->id;
|
buffer[ix++] = InvestigateMsg::id;
|
||||||
buffer[ix++] = this->networkId;
|
buffer[ix++] = this->networkId;
|
||||||
buffer[ix++] = this->thingId;
|
buffer[ix++] = this->thingId;
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
||||||
// bool InvestigateMsg::Send(Participant *participant, unsigned char networkId,
|
|
||||||
// unsigned char thingId) {
|
|
||||||
// InvestigateMsg msg = InvestigateMsg(networkId, thingId);
|
|
||||||
// return msg.Send(participant);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Investigate
|
// Investigate
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
@ -118,7 +96,7 @@ ThingMsg::ThingMsg(unsigned char networkId, unsigned char thingId,
|
|||||||
|
|
||||||
unsigned char ThingMsg::Serialize(unsigned char *buffer) {
|
unsigned char ThingMsg::Serialize(unsigned char *buffer) {
|
||||||
unsigned char ix = 0;
|
unsigned char ix = 0;
|
||||||
buffer[ix++] = this->id;
|
buffer[ix++] = ThingMsg::id;
|
||||||
buffer[ix++] = this->networkId;
|
buffer[ix++] = this->networkId;
|
||||||
buffer[ix++] = this->thingId;
|
buffer[ix++] = this->thingId;
|
||||||
buffer[ix++] = this->thingType;
|
buffer[ix++] = this->thingType;
|
||||||
@ -126,13 +104,6 @@ unsigned char ThingMsg::Serialize(unsigned char *buffer) {
|
|||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
||||||
// bool ThingMsg::Send(Participant *participant, unsigned char networkId,
|
|
||||||
// unsigned char thingId, unsigned char thingType,
|
|
||||||
// unsigned char parentId) {
|
|
||||||
// ThingMsg msg = ThingMsg(networkId, thingId, thingType, parentId);
|
|
||||||
// return msg.Send(participant);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Thing
|
// Thing
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
@ -148,7 +119,7 @@ NameMsg::NameMsg(unsigned char networkId, unsigned char thingId,
|
|||||||
|
|
||||||
unsigned char NameMsg::Serialize(unsigned char *buffer) {
|
unsigned char NameMsg::Serialize(unsigned char *buffer) {
|
||||||
unsigned char ix = 0;
|
unsigned char ix = 0;
|
||||||
buffer[ix++] = this->id;
|
buffer[ix++] = NameMsg::id;
|
||||||
buffer[ix++] = this->networkId;
|
buffer[ix++] = this->networkId;
|
||||||
buffer[ix++] = this->thingId;
|
buffer[ix++] = this->thingId;
|
||||||
buffer[ix++] = this->nameLength;
|
buffer[ix++] = this->nameLength;
|
||||||
@ -158,18 +129,6 @@ unsigned char NameMsg::Serialize(unsigned char *buffer) {
|
|||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
||||||
// bool NameMsg::Send(Participant *participant, Thing *thing,
|
|
||||||
// unsigned char nameLength) {
|
|
||||||
// if (thing->name == nullptr)
|
|
||||||
// return true; // nothing sent, but still a success!
|
|
||||||
|
|
||||||
// if (strlen(thing->name) == 0)
|
|
||||||
// return true;
|
|
||||||
|
|
||||||
// NameMsg msg = NameMsg(thing->networkId, thing->id, thing->name,
|
|
||||||
// nameLength); return msg.Send(participant);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Name
|
// Name
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
@ -187,7 +146,7 @@ ModelUrlMsg::ModelUrlMsg(unsigned char networkId, unsigned char thingId,
|
|||||||
|
|
||||||
unsigned char ModelUrlMsg::Serialize(unsigned char *buffer) {
|
unsigned char ModelUrlMsg::Serialize(unsigned char *buffer) {
|
||||||
unsigned char ix = 0;
|
unsigned char ix = 0;
|
||||||
buffer[ix++] = this->id;
|
buffer[ix++] = ModelUrlMsg::id;
|
||||||
buffer[ix++] = this->networkId;
|
buffer[ix++] = this->networkId;
|
||||||
buffer[ix++] = this->thingId;
|
buffer[ix++] = this->thingId;
|
||||||
LowLevelMessages::SendFloat16(buffer, &ix, this->scale);
|
LowLevelMessages::SendFloat16(buffer, &ix, this->scale);
|
||||||
@ -230,13 +189,13 @@ unsigned char PoseMsg::Serialize(unsigned char *buffer) {
|
|||||||
buffer[ix++] = this->networkId;
|
buffer[ix++] = this->networkId;
|
||||||
buffer[ix++] = this->thingId;
|
buffer[ix++] = this->thingId;
|
||||||
buffer[ix++] = this->poseType;
|
buffer[ix++] = this->poseType;
|
||||||
if ((this->poseType & Pose_Position) != 0)
|
if (this->poseType & Pose_Position)
|
||||||
LowLevelMessages::SendSpherical16(buffer, &ix, this->position);
|
LowLevelMessages::SendSpherical16(buffer, &ix, this->position);
|
||||||
if ((this->poseType & Pose_Orientation) != 0)
|
if (this->poseType & Pose_Orientation)
|
||||||
LowLevelMessages::SendQuat32(buffer, &ix, this->orientation);
|
LowLevelMessages::SendQuat32(buffer, &ix, this->orientation);
|
||||||
if ((this->poseType & Pose_LinearVelocity) != 0)
|
if (this->poseType & Pose_LinearVelocity)
|
||||||
LowLevelMessages::SendSpherical16(buffer, &ix, this->linearVelocity);
|
LowLevelMessages::SendSpherical16(buffer, &ix, this->linearVelocity);
|
||||||
if ((this->poseType & Pose_AngularVelocity) != 0)
|
if (this->poseType & Pose_AngularVelocity)
|
||||||
LowLevelMessages::SendSpherical16(buffer, &ix, this->angularVelocity);
|
LowLevelMessages::SendSpherical16(buffer, &ix, this->angularVelocity);
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
@ -267,7 +226,7 @@ unsigned char CustomMsg::Serialize(unsigned char *buffer) {
|
|||||||
if (ix <= this->length) // in this case, no data is actually sent
|
if (ix <= this->length) // in this case, no data is actually sent
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
buffer[0] = this->id;
|
buffer[0] = CustomMsg::id;
|
||||||
buffer[1] = this->networkId;
|
buffer[1] = this->networkId;
|
||||||
buffer[2] = this->thingId;
|
buffer[2] = this->thingId;
|
||||||
return ix;
|
return ix;
|
||||||
@ -290,7 +249,7 @@ DestroyMsg::DestroyMsg(unsigned char networkId, Thing *thing) {
|
|||||||
|
|
||||||
unsigned char DestroyMsg::Serialize(unsigned char *buffer) {
|
unsigned char DestroyMsg::Serialize(unsigned char *buffer) {
|
||||||
unsigned char ix = 0;
|
unsigned char ix = 0;
|
||||||
buffer[ix++] = this->id;
|
buffer[ix++] = DestroyMsg::id;
|
||||||
buffer[ix++] = this->networkId;
|
buffer[ix++] = this->networkId;
|
||||||
buffer[ix++] = this->thingId;
|
buffer[ix++] = this->thingId;
|
||||||
return ix;
|
return ix;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user