From d33f3e43bd46ccf3a19ff150a8d5a1c45e112b74 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 7 Jun 2013 15:28:30 -0700 Subject: [PATCH] agentTypesOfInterest need not be unsigned and remove debugging --- libraries/shared/src/AgentList.cpp | 7 +++---- libraries/shared/src/AgentList.h | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/libraries/shared/src/AgentList.cpp b/libraries/shared/src/AgentList.cpp index 982116b39a..6f38bff519 100644 --- a/libraries/shared/src/AgentList.cpp +++ b/libraries/shared/src/AgentList.cpp @@ -178,10 +178,10 @@ Agent* AgentList::agentWithID(uint16_t agentID) { return NULL; } -void AgentList::setAgentTypesOfInterest(const unsigned char* agentTypesOfInterest, int numAgentTypesOfInterest) { +void AgentList::setAgentTypesOfInterest(const char* agentTypesOfInterest, int numAgentTypesOfInterest) { delete _agentTypesOfInterest; - _agentTypesOfInterest = new unsigned char[numAgentTypesOfInterest + sizeof(char)]; + _agentTypesOfInterest = new char[numAgentTypesOfInterest + sizeof(char)]; memcpy(_agentTypesOfInterest, agentTypesOfInterest, numAgentTypesOfInterest); _agentTypesOfInterest[numAgentTypesOfInterest] = '\0'; } @@ -209,11 +209,10 @@ void AgentList::sendDomainServerCheckIn() { if (!checkInPacket) { int numBytesAgentsOfInterest = _agentTypesOfInterest ? strlen((char*) _agentTypesOfInterest) : NULL; - printf("There are %d AOI\n", numBytesAgentsOfInterest); + // check in packet has header, agent type, port, IP, agent types of interest, null termination int numPacketBytes = sizeof(PACKET_HEADER) + sizeof(AGENT_TYPE) + sizeof(uint16_t) + (sizeof(char) * 4) + numBytesAgentsOfInterest + sizeof(char); - printf("Packet as a whole will be %d\n", numPacketBytes); checkInPacket = new unsigned char[numPacketBytes]; diff --git a/libraries/shared/src/AgentList.h b/libraries/shared/src/AgentList.h index 2c07b7c34f..3007dbc8e3 100644 --- a/libraries/shared/src/AgentList.h +++ b/libraries/shared/src/AgentList.h @@ -67,7 +67,7 @@ public: void lock() { pthread_mutex_lock(&mutex); } void unlock() { pthread_mutex_unlock(&mutex); } - void setAgentTypesOfInterest(const unsigned char* agentTypesOfInterest, int numAgentTypesOfInterest); + void setAgentTypesOfInterest(const char* agentTypesOfInterest, int numAgentTypesOfInterest); void sendDomainServerCheckIn(); int processDomainServerList(unsigned char *packetData, size_t dataBytes); @@ -106,7 +106,7 @@ private: int _numAgents; UDPSocket _agentSocket; char _ownerType; - unsigned char* _agentTypesOfInterest; + char* _agentTypesOfInterest; unsigned int _socketListenPort; uint16_t _ownerID; uint16_t _lastAgentID;