Basic things seems to work, now start doing the tracker stuff
This commit is contained in:
parent
afc48a1438
commit
7b17d8459a
@ -102,7 +102,6 @@ void LocalParticipant::Receive() {
|
|||||||
char sender_ipAddress[16];
|
char sender_ipAddress[16];
|
||||||
inet_ntoa_r(this->src_addr.sin_addr, sender_ipAddress, INET_ADDRSTRLEN);
|
inet_ntoa_r(this->src_addr.sin_addr, sender_ipAddress, INET_ADDRSTRLEN);
|
||||||
unsigned int sender_port = ntohs(this->src_addr.sin_port);
|
unsigned int sender_port = ntohs(this->src_addr.sin_port);
|
||||||
std::cout << "Received from " << ntohs(this->src_addr.sin_port) << "\n";
|
|
||||||
|
|
||||||
ReceiveData(packetSize, sender_ipAddress, sender_port);
|
ReceiveData(packetSize, sender_ipAddress, sender_port);
|
||||||
|
|
||||||
|
@ -25,8 +25,6 @@
|
|||||||
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
// LocalParticipant::LocalParticipant() {}
|
|
||||||
|
|
||||||
LocalParticipant::LocalParticipant(int port) {
|
LocalParticipant::LocalParticipant(int port) {
|
||||||
this->ipAddress = "0.0.0.0";
|
this->ipAddress = "0.0.0.0";
|
||||||
this->port = port;
|
this->port = port;
|
||||||
@ -260,8 +258,8 @@ void LocalParticipant::ReceiveData(unsigned char packetSize,
|
|||||||
this->GetParticipant(senderIpAddress, senderPort);
|
this->GetParticipant(senderIpAddress, senderPort);
|
||||||
if (remoteParticipant == nullptr) {
|
if (remoteParticipant == nullptr) {
|
||||||
remoteParticipant = this->AddParticipant(senderIpAddress, senderPort);
|
remoteParticipant = this->AddParticipant(senderIpAddress, senderPort);
|
||||||
std::cout << "New sender " << senderIpAddress << ":" << senderPort
|
// std::cout << "New sender " << senderIpAddress << ":" << senderPort
|
||||||
<< "\n";
|
// << "\n";
|
||||||
std::cout << "New remote participant " << remoteParticipant->ipAddress
|
std::cout << "New remote participant " << remoteParticipant->ipAddress
|
||||||
<< ":" << remoteParticipant->port << " "
|
<< ":" << remoteParticipant->port << " "
|
||||||
<< (int)remoteParticipant->networkId << "\n";
|
<< (int)remoteParticipant->networkId << "\n";
|
||||||
@ -273,7 +271,7 @@ void LocalParticipant::ReceiveData(unsigned char packetSize,
|
|||||||
void LocalParticipant::ReceiveData(unsigned char bufferSize,
|
void LocalParticipant::ReceiveData(unsigned char bufferSize,
|
||||||
Participant* remoteParticipant) {
|
Participant* remoteParticipant) {
|
||||||
unsigned char msgId = this->buffer[0];
|
unsigned char msgId = this->buffer[0];
|
||||||
// std::cout << "receive msg " << (int)msgId << "\n";
|
//std::cout << "receive msg " << (int)msgId << "\n";
|
||||||
switch (msgId) {
|
switch (msgId) {
|
||||||
case ParticipantMsg::id: {
|
case ParticipantMsg::id: {
|
||||||
ParticipantMsg* msg = new ParticipantMsg(this->buffer);
|
ParticipantMsg* msg = new ParticipantMsg(this->buffer);
|
||||||
@ -328,9 +326,14 @@ void LocalParticipant::Process(Participant* sender, SiteMsg* msg) {
|
|||||||
|
|
||||||
void LocalParticipant::Process(Participant* sender, InvestigateMsg* msg) {}
|
void LocalParticipant::Process(Participant* sender, InvestigateMsg* msg) {}
|
||||||
|
|
||||||
void LocalParticipant::Process(Participant* sender, ThingMsg* msg) {}
|
void LocalParticipant::Process(Participant* sender, ThingMsg* msg) {
|
||||||
|
std::cout << this->name << ": process Thing [" << (int)this->networkId << "/" << (int)msg->networkId << "]\n";
|
||||||
|
}
|
||||||
|
|
||||||
void LocalParticipant::Process(Participant* sender, NameMsg* msg) {
|
void LocalParticipant::Process(Participant* sender, NameMsg* msg) {
|
||||||
|
std::cout << this->name << ": process Name [" << (int)this->networkId
|
||||||
|
<< "/" << (int)msg->networkId << "]\n";
|
||||||
|
|
||||||
Thing* thing = sender->Get(msg->networkId, msg->thingId);
|
Thing* thing = sender->Get(msg->networkId, msg->thingId);
|
||||||
if (thing != nullptr) {
|
if (thing != nullptr) {
|
||||||
int nameLength = msg->nameLength;
|
int nameLength = msg->nameLength;
|
||||||
@ -353,12 +356,12 @@ void LocalParticipant::Process(Participant* sender, NameMsg* msg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalParticipant::Process(Participant* sender, PoseMsg* msg) {}
|
void LocalParticipant::Process(Participant* sender, PoseMsg* msg) {
|
||||||
|
std::cout << this->name << ": process Pose [" << (int)this->networkId << "/" << (int)msg->networkId << "]\n";
|
||||||
|
}
|
||||||
|
|
||||||
void LocalParticipant::Process(Participant* sender, BinaryMsg* msg) {
|
void LocalParticipant::Process(Participant* sender, BinaryMsg* msg) {
|
||||||
// std::cout << this->name << ": process Binary [" << (int)this->networkId <<
|
std::cout << this->name << ": process Binary [" << (int)this->networkId << "/" << (int)msg->networkId << "]\n";
|
||||||
// "/"
|
|
||||||
// << (int)msg->networkId << "]\n";
|
|
||||||
Thing* thing = sender->Get(msg->networkId, msg->thingId);
|
Thing* thing = sender->Get(msg->networkId, msg->thingId);
|
||||||
if (thing != nullptr)
|
if (thing != nullptr)
|
||||||
thing->ProcessBinary(msg->bytes);
|
thing->ProcessBinary(msg->bytes);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user