Improved output formatting and added new command 'c' for more information on client connections

parent cc2ed6cb
......@@ -47,12 +47,12 @@ int main( int argc, char* argv[] )
if( argc == 1 )
{
sServerAddress = "0.0.0.0:12340";
cout << "No bind address and port given, using default: " << sServerAddress << endl;
cout << "[ VAServer ] No bind address and port given, using default: " << sServerAddress << endl;
string sDefaultConfigFile = "VACore.ini";
if( doesFileExist( sDefaultConfigFile ) )
{
sVACoreConfigPath = sDefaultConfigFile;
cout << "[VAServer ] Using default configuration file '" << sVACoreConfigPath << "'." << endl;
cout << "[ VAServer ] Using default configuration file '" << sVACoreConfigPath << "'." << endl;
}
}
else
......@@ -112,7 +112,7 @@ int main( int argc, char* argv[] )
}
else
{
cout << "[VAServer ] Core configuration path: " << correctPath( sVACoreConfigPath ) << endl;
cout << "[ VAServer ] Core configuration path: " << correctPath( sVACoreConfigPath ) << endl;
pCore = VACore::CreateCoreInstance( sVACoreConfigPath );
}
......@@ -121,7 +121,7 @@ int main( int argc, char* argv[] )
{
CVACoreVersionInfo ver;
pCore->GetVersionInfo( &ver );
cout << ver.ToString() << endl;
cout << "[ VAServer ] " << ver.ToString() << endl;
delete pCore;
return 0;
......@@ -142,23 +142,24 @@ int main( int argc, char* argv[] )
if( ( ec = pServer->Initialize( sServer, iPort ) ) != 0 )
{
cerr << "Failed to initialize network communication (errorcode " << ec << ")" << endl;
cerr << "[ VAServer ][Error ] Failed to initialize network communication (errorcode " << ec << ")" << endl;
return ec;
}
CVACoreVersionInfo ver;
pCore->GetVersionInfo( &ver );
cout << endl << "[VAServer ] Core version: " << ver.ToString() << endl;
cout << "[VAServer ] Successfully started and listening on " << sServer << ":" << iPort << endl << endl;
cout << "Controls:\n\n" <<
" m Toggle output muting" << endl <<
" + Increase output gain by 3dB" << endl <<
" 0 Output gain 0dB" << endl <<
" - Decrease output gain by 3dB" << endl <<
" r Reset core" << endl <<
" l Circulate log levels" << endl <<
" q Quit" << endl << endl;
cout << endl << "[ VAServer ] Core version: " << ver.ToString() << endl;
cout << "[ VAServer ] Successfully started and listening on " << sServer << ":" << iPort << endl << endl;
cout << "[ VAServer ] Controls:\n" <<
"[ VAServer ] m Toggle output muting" << endl <<
"[ VAServer ] + Increase output gain by 3dB" << endl <<
"[ VAServer ] 0 Output gain 0dB" << endl <<
"[ VAServer ] - Decrease output gain by 3dB" << endl <<
"[ VAServer ] r Reset core" << endl <<
"[ VAServer ] l Circulate log levels" << endl <<
"[ VAServer ] c List connected clients" << endl <<
"[ VAServer ] q Quit" << endl << endl;
while( true )
{
......@@ -170,13 +171,13 @@ int main( int argc, char* argv[] )
if( ( char ) c == 'm' )
{
bool bMuted = pServer->GetCoreInstance()->IsOutputMuted();
cout << ( !bMuted ? "Muting" : "Unmuting" ) << " global output" << endl;
cout << "[ VAServer ] " << ( !bMuted ? "Muting" : "Unmuting" ) << " global output" << endl;
pServer->GetCoreInstance()->SetOutputMuted( !bMuted );
}
if( ( char ) c == '0' )
{
cout << "Setting output gain to 0 dB" << endl;
cout << "[ VAServer ] Setting output gain to 0 dB" << endl;
pServer->GetCoreInstance()->SetOutputGain( 1.0 );
}
......@@ -184,7 +185,7 @@ int main( int argc, char* argv[] )
{
double dGain = pServer->GetCoreInstance()->GetOutputGain();
dGain *= 1.4125;
cout << "Setting output gain to " << ratio_to_db20_str( dGain ) << endl;
cout << "[ VAServer ] Setting output gain to " << ratio_to_db20_str( dGain ) << endl;
pServer->GetCoreInstance()->SetOutputGain( dGain );
}
......@@ -192,7 +193,7 @@ int main( int argc, char* argv[] )
{
double dGain = pServer->GetCoreInstance()->GetOutputGain();
dGain /= 1.4125;
cout << "Setting output gain to " << ratio_to_db20_str( dGain ) << endl;
cout << "[ VAServer ] Setting output gain to " << ratio_to_db20_str( dGain ) << endl;
pServer->GetCoreInstance()->SetOutputGain( dGain );
}
......@@ -200,24 +201,44 @@ int main( int argc, char* argv[] )
{
CVAStruct oArgs, oReturn, oNewArgs;
oArgs[ "command" ] = "get";
oArgs[ std::string("debug") ] = CVAStruct();
oArgs[ std::string("debug") ][ std::string("loglevel") ] = true;
oArgs[ std::string( "debug" ) ] = CVAStruct();
oArgs[ std::string( "debug" ) ][ std::string( "loglevel" ) ] = true;
pServer->GetCoreInstance()->CallModule( "VACore", oArgs, oReturn );
int iCurrentLogLevel = oReturn[ std::string("debug") ][ std::string("loglevel") ];
int iCurrentLogLevel = oReturn[ std::string( "debug" ) ][ std::string( "loglevel" ) ];
int iNewLogLevel = int( iCurrentLogLevel + 1 ) % 6;
oNewArgs[ "command" ] = "set";
oNewArgs[ "debug" ] = CVAStruct();
oNewArgs[ std::string("debug") ][ std::string("loglevel") ] = iNewLogLevel;
oNewArgs[ std::string( "debug" ) ][ std::string( "loglevel" ) ] = iNewLogLevel;
pServer->GetCoreInstance()->CallModule( "VACore", oNewArgs, oReturn );
cout << "Switched to log level: " << IVACore::GetLogLevelStr( iNewLogLevel ) << endl;
cout << "[ VAServer ] Switched to log level: " << IVACore::GetLogLevelStr( iNewLogLevel ) << endl;
}
if( ( char ) c == 'r' )
{
cout << "Resetting server manually" << endl;
cout << "[ VAServer ] Resetting server manually" << endl;
pServer->GetCoreInstance()->Reset();
}
if( ( char ) c == 'c' )
{
if( !pServer->IsClientConnected() )
{
cout << "[ VAServer ] Nothing yet, still waiting for connections" << endl;
}
else
{
const int iNumClients = pServer->GetNumConnectedClients();
if( iNumClients == 1 )
cout << "[ VAServer ] One client connected" << endl;
else
cout << "[ VAServer ] Counting " << iNumClients << " connections" << endl;
for( int i = 0; i < iNumClients; i++ )
{
cout << "[ VAServer ] + " << pServer->GetClientHostname( i ) << endl;
}
}
}
}
delete pServer;
......@@ -227,7 +248,7 @@ int main( int argc, char* argv[] )
}
catch( CVAException& e )
{
cerr << "Error: " << e << endl;
cerr << "[ VAServer ][ Error ] " << e << endl;
delete pServer;
if( pCore )
......@@ -243,7 +264,7 @@ int main( int argc, char* argv[] )
pCore->Finalize();
delete pCore;
cerr << "Error: An unknown error occured" << endl;
cerr << "[ VAServer ][ Error ] An unknown error occured" << endl;
return 255;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment