mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 05:52:38 +02:00
first cut at making VoxelServer class run with configuration or standalone
This commit is contained in:
parent
25d9281496
commit
2388cfc8e0
5 changed files with 34 additions and 18 deletions
|
@ -32,6 +32,7 @@ pid_t* childForks = NULL;
|
|||
sockaddr_in customAssignmentSocket = {};
|
||||
int numForks = 0;
|
||||
Assignment::Type overiddenAssignmentType = Assignment::AllTypes;
|
||||
std::vector<VoxelServer*> voxelServers;
|
||||
|
||||
void childClient() {
|
||||
// this is one of the child forks or there is a single assignment client, continue assignment-client execution
|
||||
|
@ -100,7 +101,9 @@ void childClient() {
|
|||
} else if (deployedAssignment.getType() == Assignment::AvatarMixerType) {
|
||||
AvatarMixer::run();
|
||||
} else if (deployedAssignment.getType() == Assignment::VoxelServerType) {
|
||||
VoxelServer::run();
|
||||
VoxelServer* voxelServer = new VoxelServer();
|
||||
::voxelServers.push_back(voxelServer);
|
||||
voxelServer->run((const char*)deployedAssignment.getPayload());
|
||||
} else {
|
||||
// figure out the URL for the script for this agent assignment
|
||||
QString scriptURLString("http://%1:8080/assignment/%2");
|
||||
|
@ -162,6 +165,13 @@ void sigchldHandler(int sig) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// cleanup voxelServers
|
||||
for (int i = 0; i < ::voxelServers.size(); i++) {
|
||||
VoxelServer* voxelServer = ::voxelServers[i];
|
||||
delete voxelServer;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void parentMonitor() {
|
||||
|
|
|
@ -169,7 +169,7 @@ int main(int argc, const char* argv[]) {
|
|||
if (voxelServerConfig) {
|
||||
qDebug("Reading Voxel Server Configuration.\n");
|
||||
qDebug() << " config: " << voxelServerConfig << "\n";
|
||||
voxelServerAssignment.setDataPayload((unsigned char*)voxelServerConfig, strlen(voxelServerConfig) + 1);
|
||||
voxelServerAssignment.setPayload((uchar*)voxelServerConfig, strlen(voxelServerConfig) + 1);
|
||||
}
|
||||
|
||||
// construct a local socket to send with our created assignments to the global AS
|
||||
|
|
|
@ -63,22 +63,24 @@ VoxelPersistThread* voxelPersistThread = NULL;
|
|||
pthread_mutex_t treeLock;
|
||||
NodeWatcher nodeWatcher; // used to cleanup AGENT data when agents are killed
|
||||
|
||||
int VoxelServer::_argc = 0;
|
||||
const char** VoxelServer::_argv = NULL;
|
||||
bool VoxelServer::_dontKillOnMissingDomain = false;
|
||||
|
||||
void attachVoxelNodeDataToNode(Node* newNode) {
|
||||
if (newNode->getLinkedData() == NULL) {
|
||||
newNode->setLinkedData(new VoxelNodeData(newNode));
|
||||
}
|
||||
}
|
||||
|
||||
VoxelServer::VoxelServer() {
|
||||
_argc = 0;
|
||||
_argv = NULL;
|
||||
_dontKillOnMissingDomain = false;
|
||||
}
|
||||
|
||||
void VoxelServer::setArguments(int argc, char** argv) {
|
||||
_argc = argc;
|
||||
_argv = const_cast<const char**>(argv);
|
||||
}
|
||||
|
||||
void VoxelServer::setupDomainAndPort(const char* domain, int port) {
|
||||
void VoxelServer::setupStandAlone(const char* domain, int port) {
|
||||
NodeList::createInstance(NODE_TYPE_VOXEL_SERVER, port);
|
||||
|
||||
// Handle Local Domain testing with the --local command line
|
||||
|
@ -98,7 +100,7 @@ void VoxelServer::setupDomainAndPort(const char* domain, int port) {
|
|||
}
|
||||
|
||||
//int main(int argc, const char * argv[]) {
|
||||
void VoxelServer::run() {
|
||||
void VoxelServer::run(const char* configuration) {
|
||||
pthread_mutex_init(&::treeLock, NULL);
|
||||
|
||||
qInstallMessageHandler(sharedMessageHandler);
|
||||
|
|
|
@ -12,23 +12,25 @@
|
|||
/// Handles assignments of type VoxelServer - sending voxels to various clients.
|
||||
class VoxelServer {
|
||||
public:
|
||||
VoxelServer();
|
||||
|
||||
/// runs the voxel server assignment
|
||||
static void run();
|
||||
void run(const char* configuration = NULL);
|
||||
|
||||
/// allows setting of run arguments
|
||||
static void setArguments(int argc, char** argv);
|
||||
void setArguments(int argc, char** argv);
|
||||
|
||||
/// when VoxelServer class is used by voxel-server stand alone executable it calls this to specify the domain
|
||||
/// and port it is handling. When called by assignment-client, this is not needed because assignment-client
|
||||
/// handles ports and domains automatically.
|
||||
/// \param const char* domain domain name, IP address, or local to specify the domain the voxel server is serving
|
||||
/// \param int port port the voxel server will listen on
|
||||
static void setupDomainAndPort(const char* domain, int port);
|
||||
void setupStandAlone(const char* domain, int port);
|
||||
|
||||
private:
|
||||
static int _argc;
|
||||
static const char** _argv;
|
||||
static bool _dontKillOnMissingDomain;
|
||||
int _argc;
|
||||
const char** _argv;
|
||||
bool _dontKillOnMissingDomain;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -29,17 +29,19 @@ int main(int argc, const char * argv[]) {
|
|||
}
|
||||
printf("portParameter=%s listenPort=%d\n", portParameter, listenPort);
|
||||
}
|
||||
|
||||
VoxelServer ourVoxelServer;
|
||||
|
||||
if (wantLocalDomain) {
|
||||
VoxelServer::setupDomainAndPort(local, listenPort);
|
||||
ourVoxelServer.setupStandAlone(local, listenPort);
|
||||
} else {
|
||||
if (domainIP) {
|
||||
VoxelServer::setupDomainAndPort(domainIP, listenPort);
|
||||
ourVoxelServer.setupStandAlone(domainIP, listenPort);
|
||||
}
|
||||
}
|
||||
|
||||
VoxelServer::setArguments(argc, const_cast<char**>(argv));
|
||||
VoxelServer::run();
|
||||
ourVoxelServer.setArguments(argc, const_cast<char**>(argv));
|
||||
ourVoxelServer.run();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue