mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 17:49:27 +02:00
Adding new AgentTypes.h and moving over to new constants
This commit is contained in:
parent
60dc43041f
commit
2ec3f6b210
6 changed files with 39 additions and 10 deletions
|
@ -25,6 +25,8 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include "AgentList.h"
|
#include "AgentList.h"
|
||||||
|
#include "AgentTypes.h"
|
||||||
|
#include <PacketHeaders.h>
|
||||||
#include "SharedUtil.h"
|
#include "SharedUtil.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -46,7 +48,7 @@ const int LOGOFF_CHECK_INTERVAL = 5000;
|
||||||
#define DEBUG_TO_SELF 0
|
#define DEBUG_TO_SELF 0
|
||||||
|
|
||||||
int lastActiveCount = 0;
|
int lastActiveCount = 0;
|
||||||
AgentList agentList('D', DOMAIN_LISTEN_PORT);
|
AgentList agentList(AGENT_TYPE_DOMAIN, DOMAIN_LISTEN_PORT);
|
||||||
|
|
||||||
unsigned char * addAgentToBroadcastPacket(unsigned char *currentPosition, Agent *agentToAdd) {
|
unsigned char * addAgentToBroadcastPacket(unsigned char *currentPosition, Agent *agentToAdd) {
|
||||||
*currentPosition++ = agentToAdd->getType();
|
*currentPosition++ = agentToAdd->getType();
|
||||||
|
@ -82,7 +84,7 @@ int main(int argc, const char * argv[])
|
||||||
char agentType;
|
char agentType;
|
||||||
|
|
||||||
unsigned char *broadcastPacket = new unsigned char[MAX_PACKET_SIZE];
|
unsigned char *broadcastPacket = new unsigned char[MAX_PACKET_SIZE];
|
||||||
*broadcastPacket = 'D';
|
*broadcastPacket = PACKET_HEADER_DOMAIN;
|
||||||
|
|
||||||
unsigned char *currentBufferPos;
|
unsigned char *currentBufferPos;
|
||||||
unsigned char *startPointer;
|
unsigned char *startPointer;
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
#include "Texture.h"
|
#include "Texture.h"
|
||||||
#include "Cloud.h"
|
#include "Cloud.h"
|
||||||
#include <AgentList.h>
|
#include <AgentList.h>
|
||||||
|
#include <AgentTypes.h>
|
||||||
#include "VoxelSystem.h"
|
#include "VoxelSystem.h"
|
||||||
#include "Lattice.h"
|
#include "Lattice.h"
|
||||||
#include "Finger.h"
|
#include "Finger.h"
|
||||||
|
@ -70,7 +71,7 @@ using namespace std;
|
||||||
int audio_on = 1; // Whether to turn on the audio support
|
int audio_on = 1; // Whether to turn on the audio support
|
||||||
int simulate_on = 1;
|
int simulate_on = 1;
|
||||||
|
|
||||||
AgentList agentList('I');
|
AgentList agentList(AGENT_TYPE_INTERFACE);
|
||||||
pthread_t networkReceiveThread;
|
pthread_t networkReceiveThread;
|
||||||
bool stopNetworkReceiveThread = false;
|
bool stopNetworkReceiveThread = false;
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <AgentList.h>
|
#include <AgentList.h>
|
||||||
|
#include <AgentTypes.h>
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
#include <StdDev.h>
|
#include <StdDev.h>
|
||||||
#include "AudioRingBuffer.h"
|
#include "AudioRingBuffer.h"
|
||||||
|
@ -60,7 +61,7 @@ const int AGENT_LOOPBACK_MODIFIER = 307;
|
||||||
|
|
||||||
const int LOOPBACK_SANITY_CHECK = 0;
|
const int LOOPBACK_SANITY_CHECK = 0;
|
||||||
|
|
||||||
AgentList agentList('M', MIXER_LISTEN_PORT);
|
AgentList agentList(AGENT_TYPE_MIXER, MIXER_LISTEN_PORT);
|
||||||
StDev stdev;
|
StDev stdev;
|
||||||
|
|
||||||
void plateauAdditionOfSamples(int16_t &mixSample, int16_t sampleToAdd) {
|
void plateauAdditionOfSamples(int16_t &mixSample, int16_t sampleToAdd) {
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include "AgentList.h"
|
#include "AgentList.h"
|
||||||
|
#include "AgentTypes.h"
|
||||||
#include "PacketHeaders.h"
|
#include "PacketHeaders.h"
|
||||||
#include "SharedUtil.h"
|
#include "SharedUtil.h"
|
||||||
|
|
||||||
|
@ -180,13 +181,13 @@ bool AgentList::addOrUpdateAgent(sockaddr *publicSocket, sockaddr *localSocket,
|
||||||
newAgent.activatePublicSocket();
|
newAgent.activatePublicSocket();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newAgent.getType() == 'M' && audioMixerSocketUpdate != NULL) {
|
if (newAgent.getType() == AGENT_TYPE_MIXER && audioMixerSocketUpdate != NULL) {
|
||||||
// this is an audio mixer
|
// this is an audio mixer
|
||||||
// for now that means we need to tell the audio class
|
// for now that means we need to tell the audio class
|
||||||
// to use the local socket information the domain server gave us
|
// to use the local socket information the domain server gave us
|
||||||
sockaddr_in *publicSocketIn = (sockaddr_in *)publicSocket;
|
sockaddr_in *publicSocketIn = (sockaddr_in *)publicSocket;
|
||||||
audioMixerSocketUpdate(publicSocketIn->sin_addr.s_addr, publicSocketIn->sin_port);
|
audioMixerSocketUpdate(publicSocketIn->sin_addr.s_addr, publicSocketIn->sin_port);
|
||||||
} else if (newAgent.getType() == 'V') {
|
} else if (newAgent.getType() == AGENT_TYPE_VOXEL) {
|
||||||
newAgent.activatePublicSocket();
|
newAgent.activatePublicSocket();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +200,7 @@ bool AgentList::addOrUpdateAgent(sockaddr *publicSocket, sockaddr *localSocket,
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (agent->getType() == 'M' || agent->getType() == 'V') {
|
if (agent->getType() == AGENT_TYPE_MIXER || agent->getType() == AGENT_TYPE_VOXEL) {
|
||||||
// until the Audio class also uses our agentList, we need to update
|
// until the Audio class also uses our agentList, we need to update
|
||||||
// the lastRecvTimeUsecs for the audio mixer so it doesn't get killed and re-added continously
|
// the lastRecvTimeUsecs for the audio mixer so it doesn't get killed and re-added continously
|
||||||
agent->setLastRecvTimeUsecs(usecTimestampNow());
|
agent->setLastRecvTimeUsecs(usecTimestampNow());
|
||||||
|
@ -210,6 +211,7 @@ bool AgentList::addOrUpdateAgent(sockaddr *publicSocket, sockaddr *localSocket,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXXBHG - do we want to move these?
|
||||||
const char* AgentList::AGENTS_OF_TYPE_HEAD = "H";
|
const char* AgentList::AGENTS_OF_TYPE_HEAD = "H";
|
||||||
const char* AgentList::AGENTS_OF_TYPE_VOXEL_AND_INTERFACE = "VI";
|
const char* AgentList::AGENTS_OF_TYPE_VOXEL_AND_INTERFACE = "VI";
|
||||||
const char* AgentList::AGENTS_OF_TYPE_VOXEL = "V";
|
const char* AgentList::AGENTS_OF_TYPE_VOXEL = "V";
|
||||||
|
@ -229,7 +231,7 @@ void AgentList::pingAgents() {
|
||||||
*payload = PACKET_HEADER_PING;
|
*payload = PACKET_HEADER_PING;
|
||||||
|
|
||||||
for(std::vector<Agent>::iterator agent = agents.begin(); agent != agents.end(); agent++) {
|
for(std::vector<Agent>::iterator agent = agents.begin(); agent != agents.end(); agent++) {
|
||||||
if (agent->getType() == 'I') {
|
if (agent->getType() == AGENT_TYPE_INTERFACE) {
|
||||||
if (agent->getActiveSocket() != NULL) {
|
if (agent->getActiveSocket() != NULL) {
|
||||||
// we know which socket is good for this agent, send there
|
// we know which socket is good for this agent, send there
|
||||||
agentSocket.send(agent->getActiveSocket(), payload, 1);
|
agentSocket.send(agent->getActiveSocket(), payload, 1);
|
||||||
|
@ -268,7 +270,8 @@ void *removeSilentAgents(void *args) {
|
||||||
|
|
||||||
pthread_mutex_t * agentDeleteMutex = &agent->deleteMutex;
|
pthread_mutex_t * agentDeleteMutex = &agent->deleteMutex;
|
||||||
|
|
||||||
if ((checkTimeUSecs - agent->getLastRecvTimeUsecs()) > AGENT_SILENCE_THRESHOLD_USECS && agent->getType() != 'V'
|
if ((checkTimeUSecs - agent->getLastRecvTimeUsecs()) > AGENT_SILENCE_THRESHOLD_USECS
|
||||||
|
&& agent->getType() != AGENT_TYPE_VOXEL
|
||||||
&& pthread_mutex_trylock(agentDeleteMutex) == 0) {
|
&& pthread_mutex_trylock(agentDeleteMutex) == 0) {
|
||||||
|
|
||||||
std::cout << "Killing agent " << &(*agent) << "\n";
|
std::cout << "Killing agent " << &(*agent) << "\n";
|
||||||
|
|
21
shared/src/AgentTypes.h
Normal file
21
shared/src/AgentTypes.h
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
//
|
||||||
|
// AgentTypes.h
|
||||||
|
// hifi
|
||||||
|
//
|
||||||
|
// Created by Brad Hefta-Gaub on 2013/04/09
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Single byte/character Agent Types used to identify various agents in the system.
|
||||||
|
// For example, an agent whose is 'V' is always a voxel server.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef hifi_AgentTypes_h
|
||||||
|
#define hifi_AgentTypes_h
|
||||||
|
|
||||||
|
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_HEAD = 'H'; // Is this needed???
|
||||||
|
const char AGENT_TYPE_MIXER = 'M';
|
||||||
|
|
||||||
|
#endif
|
|
@ -13,6 +13,7 @@
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <OctalCode.h>
|
#include <OctalCode.h>
|
||||||
#include <AgentList.h>
|
#include <AgentList.h>
|
||||||
|
#include <AgentTypes.h>
|
||||||
#include <VoxelTree.h>
|
#include <VoxelTree.h>
|
||||||
#include "VoxelAgentData.h"
|
#include "VoxelAgentData.h"
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
|
@ -45,7 +46,7 @@ const int PACKETS_PER_CLIENT_PER_INTERVAL = 2;
|
||||||
|
|
||||||
const int MAX_VOXEL_TREE_DEPTH_LEVELS = 4;
|
const int MAX_VOXEL_TREE_DEPTH_LEVELS = 4;
|
||||||
|
|
||||||
AgentList agentList('V', VOXEL_LISTEN_PORT);
|
AgentList agentList(AGENT_TYPE_VOXEL, VOXEL_LISTEN_PORT);
|
||||||
VoxelTree randomTree;
|
VoxelTree randomTree;
|
||||||
|
|
||||||
bool wantColorRandomizer = false;
|
bool wantColorRandomizer = false;
|
||||||
|
|
Loading…
Reference in a new issue