Exemplo n.º 1
0
void DomainServer::prepopulateStaticAssignmentFile() {
    int numFreshStaticAssignments = 0;
    
    // write a fresh static assignment array to file
    
    Assignment freshStaticAssignments[MAX_STATIC_ASSIGNMENT_FILE_ASSIGNMENTS];
    
    // pre-populate the first static assignment list with assignments for root AuM, AvM, VS
    freshStaticAssignments[numFreshStaticAssignments++] = Assignment(Assignment::CreateCommand, Assignment::AudioMixerType);
    freshStaticAssignments[numFreshStaticAssignments++] = Assignment(Assignment::CreateCommand, Assignment::AvatarMixerType);
    
    // Handle Domain/Voxel Server configuration command line arguments
    if (_voxelServerConfig) {
        qDebug("Reading Voxel Server Configuration.\n");
        qDebug() << "config: " << _voxelServerConfig << "\n";
        
        QString multiConfig((const char*) _voxelServerConfig);
        QStringList multiConfigList = multiConfig.split(";");
        
        // read each config to a payload for a VS assignment
        for (int i = 0; i < multiConfigList.size(); i++) {
            QString config = multiConfigList.at(i);
            
            qDebug("config[%d]=%s\n", i, config.toLocal8Bit().constData());
            
            // Now, parse the config to check for a pool
            const char ASSIGNMENT_CONFIG_POOL_OPTION[] = "--pool";
            QString assignmentPool;
            
            int poolIndex = config.indexOf(ASSIGNMENT_CONFIG_POOL_OPTION);
            
            if (poolIndex >= 0) {
                int spaceBeforePoolIndex = config.indexOf(' ', poolIndex);
                int spaceAfterPoolIndex = config.indexOf(' ', spaceBeforePoolIndex);
                
                assignmentPool = config.mid(spaceBeforePoolIndex + 1, spaceAfterPoolIndex);
                qDebug() << "The pool for this voxel-assignment is" << assignmentPool << "\n";
            }
            
            Assignment voxelServerAssignment(Assignment::CreateCommand,
                                             Assignment::VoxelServerType,
                                             (assignmentPool.isEmpty() ? NULL : assignmentPool.toLocal8Bit().constData()));
            
            int payloadLength = config.length() + sizeof(char);
            voxelServerAssignment.setPayload((uchar*)config.toLocal8Bit().constData(), payloadLength);
            
            freshStaticAssignments[numFreshStaticAssignments++] = voxelServerAssignment;
        }
    } else {
        Assignment rootVoxelServerAssignment(Assignment::CreateCommand, Assignment::VoxelServerType);
        freshStaticAssignments[numFreshStaticAssignments++] = rootVoxelServerAssignment;
    }
    
    qDebug() << "Adding" << numFreshStaticAssignments << "static assignments to fresh file.\n";
    
    _staticAssignmentFile.open(QIODevice::WriteOnly);
    _staticAssignmentFile.write((char*) &freshStaticAssignments, sizeof(freshStaticAssignments));
    _staticAssignmentFile.resize(MAX_STATIC_ASSIGNMENT_FILE_ASSIGNMENTS * sizeof(Assignment));
    _staticAssignmentFile.close();
}
Exemplo n.º 2
0
void DomainServer::prepopulateStaticAssignmentFile() {
    int numFreshStaticAssignments = 0;
    
    // write a fresh static assignment array to file
    
    Assignment freshStaticAssignments[MAX_STATIC_ASSIGNMENT_FILE_ASSIGNMENTS];
    
    // pre-populate the first static assignment list with assignments for root AuM, AvM, VS
    freshStaticAssignments[numFreshStaticAssignments++] = Assignment(Assignment::CreateCommand,
                                           Assignment::AudioMixerType,
                                           Assignment::LocalLocation);
    freshStaticAssignments[numFreshStaticAssignments++] = Assignment(Assignment::CreateCommand,
                                           Assignment::AvatarMixerType,
                                           Assignment::LocalLocation);
    
    // Handle Domain/Voxel Server configuration command line arguments
    if (_voxelServerConfig) {
        qDebug("Reading Voxel Server Configuration.\n");
        qDebug() << "config: " << _voxelServerConfig << "\n";
        
        QString multiConfig((const char*) _voxelServerConfig);
        QStringList multiConfigList = multiConfig.split(";");
        
        // read each config to a payload for a VS assignment
        for (int i = 0; i < multiConfigList.size(); i++) {
            QString config = multiConfigList.at(i);
            
            qDebug("config[%d]=%s\n", i, config.toLocal8Bit().constData());
            
            Assignment voxelServerAssignment(Assignment::CreateCommand,
                                             Assignment::VoxelServerType,
                                             Assignment::LocalLocation); // use same location as we were created in.
            
            int payloadLength = config.length() + sizeof(char);
            voxelServerAssignment.setPayload((uchar*)config.toLocal8Bit().constData(), payloadLength);
            
            freshStaticAssignments[numFreshStaticAssignments++] = voxelServerAssignment;
        }
    } else {
        Assignment rootVoxelServerAssignment(Assignment::CreateCommand,
                                             Assignment::VoxelServerType,
                                             Assignment::LocalLocation);
        freshStaticAssignments[numFreshStaticAssignments++] = rootVoxelServerAssignment;
    }
    
    qDebug() << "Adding" << numFreshStaticAssignments << "static assignments to fresh file.\n";
    
    _staticAssignmentFile.open(QIODevice::WriteOnly);
    _staticAssignmentFile.write((char*) &freshStaticAssignments, sizeof(freshStaticAssignments));
    _staticAssignmentFile.resize(MAX_STATIC_ASSIGNMENT_FILE_ASSIGNMENTS * sizeof(Assignment));
    _staticAssignmentFile.close();
}