From c68ec079eba32ed779d1feb436c828a88f959983 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 22 Apr 2013 11:54:24 -0700 Subject: [PATCH] rename AGENT_TYPE_INTERFACE to AGENT_TYPE_AVATAR, more stubbing for eve --- eve/src/main.cpp | 48 ++++++++++++++++++++++++++++++- interface/src/Head.cpp | 2 +- interface/src/main.cpp | 2 +- libraries/shared/src/Agent.cpp | 2 +- libraries/shared/src/AgentTypes.h | 2 +- voxel-server/src/main.cpp | 8 +++--- 6 files changed, 55 insertions(+), 9 deletions(-) diff --git a/eve/src/main.cpp b/eve/src/main.cpp index 05159dd9c0..0533ffe7ea 100644 --- a/eve/src/main.cpp +++ b/eve/src/main.cpp @@ -6,8 +6,54 @@ // Copyright (c) 2013 High Fidelity, Inc. All rights reserved. // -int main(int argc, char* argv[]) { +#include +#include +#include +const int EVE_AGENT_LIST_PORT = 55441; + +bool stopReceiveAgentDataThread; + +void *receiveAgentData(void *args) +{ + sockaddr senderAddress; + ssize_t bytesReceived; + unsigned char incomingPacket[MAX_PACKET_SIZE]; + + while (!::stopReceiveAgentDataThread) { + if (AgentList::getInstance()->getAgentSocket().receive(&senderAddress, incomingPacket, &bytesReceived)) { + + // we're going to ignore any data that isn't the agent list from the domain server + // ex: the avatar mixer will be sending us the position of other agents + switch (incomingPacket[0]) { + case PACKET_HEADER_DOMAIN: + AgentList::getInstance()->processAgentData(&senderAddress, incomingPacket, bytesReceived); + break; + } + } + } + + pthread_exit(0); + return NULL; +} + +int main(int argc, char* argv[]) { + // create an AgentList instance to handle communication with other agents + AgentList *agentList = AgentList::createInstance(AGENT_TYPE_AVATAR, EVE_AGENT_LIST_PORT); + + // start telling the domain server that we are alive + agentList->startDomainServerCheckInThread(); + + // start the agent list thread that will kill off agents when they stop talking + agentList->startSilentAgentRemovalThread(); + + // start the ping thread that hole punches to create an active connection to other agents + agentList->startPingUnknownAgentsThread(); + + // stop the agent list's threads + agentList->stopDomainServerCheckInThread(); + agentList->stopPingUnknownAgentsThread(); + agentList->stopSilentAgentRemovalThread(); } diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index 50ebeed4ae..abba74eb5f 100644 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -331,7 +331,7 @@ void Head::simulate(float deltaTime) { for(std::vector::iterator agent = agentList->getAgents().begin(); agent != agentList->getAgents().end(); agent++) { - if (( agent->getLinkedData() != NULL && ( agent->getType() == AGENT_TYPE_INTERFACE ) )) { + if (( agent->getLinkedData() != NULL && ( agent->getType() == AGENT_TYPE_AVATAR ) )) { Head *otherAvatar = (Head *)agent->getLinkedData(); // when this is working, I will grab the position here... diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 488f9f29b1..aad8a9be74 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -1630,7 +1630,7 @@ int main(int argc, const char * argv[]) return EXIT_SUCCESS; } - AgentList::createInstance(AGENT_TYPE_INTERFACE); + AgentList::createInstance(AGENT_TYPE_AVATAR); gettimeofday(&applicationStartupTime, NULL); const char* domainIP = getCmdOption(argc, argv, "--domain"); diff --git a/libraries/shared/src/Agent.cpp b/libraries/shared/src/Agent.cpp index d05afe5e26..819e4c185f 100644 --- a/libraries/shared/src/Agent.cpp +++ b/libraries/shared/src/Agent.cpp @@ -132,7 +132,7 @@ const char* Agent::getTypeName() const { case AGENT_TYPE_VOXEL: name = AGENT_TYPE_NAME_VOXEL; break; - case AGENT_TYPE_INTERFACE: + case AGENT_TYPE_AVATAR: name = AGENT_TYPE_NAME_INTERFACE; break; case AGENT_TYPE_AUDIO_MIXER: diff --git a/libraries/shared/src/AgentTypes.h b/libraries/shared/src/AgentTypes.h index a5d79efac8..c43af79446 100644 --- a/libraries/shared/src/AgentTypes.h +++ b/libraries/shared/src/AgentTypes.h @@ -20,7 +20,7 @@ // Agent Type Codes const char AGENT_TYPE_DOMAIN = 'D'; const char AGENT_TYPE_VOXEL = 'V'; -const char AGENT_TYPE_INTERFACE = 'I'; // could also be injector??? +const char AGENT_TYPE_AVATAR = 'I'; // could also be injector??? const char AGENT_TYPE_AUDIO_MIXER = 'M'; const char AGENT_TYPE_AVATAR_MIXER = 'W'; diff --git a/voxel-server/src/main.cpp b/voxel-server/src/main.cpp index 8f6bab7dc7..942fbb63b9 100644 --- a/voxel-server/src/main.cpp +++ b/voxel-server/src/main.cpp @@ -345,7 +345,7 @@ int main(int argc, const char * argv[]) // Now send this to the connected agents so they know to delete printf("rebroadcasting delete voxel message to connected agents... agentList.broadcastToAgents()\n"); - agentList->broadcastToAgents(packetData,receivedBytes, &AGENT_TYPE_INTERFACE, 1); + agentList->broadcastToAgents(packetData,receivedBytes, &AGENT_TYPE_AVATAR, 1); } if (packetData[0] == PACKET_HEADER_Z_COMMAND) { @@ -373,14 +373,14 @@ int main(int argc, const char * argv[]) // Now send this to the connected agents so they can also process these messages printf("rebroadcasting Z message to connected agents... agentList.broadcastToAgents()\n"); - agentList->broadcastToAgents(packetData,receivedBytes, &AGENT_TYPE_INTERFACE, 1); + agentList->broadcastToAgents(packetData,receivedBytes, &AGENT_TYPE_AVATAR, 1); } - // If we got a PACKET_HEADER_HEAD_DATA, then we're talking to an AGENT_TYPE_INTERFACE, and we + // If we got a PACKET_HEADER_HEAD_DATA, then we're talking to an AGENT_TYPE_AVATAR, and we // need to make sure we have it in our agentList. if (packetData[0] == PACKET_HEADER_HEAD_DATA) { if (agentList->addOrUpdateAgent(&agentPublicAddress, &agentPublicAddress, - AGENT_TYPE_INTERFACE, + AGENT_TYPE_AVATAR, agentList->getLastAgentId())) { agentList->increaseAgentId(); }