Extending license for 2020 and switching to version v2020.a and adding feature...

Extending license for 2020 and switching to version v2020.a and adding feature to run in remote mode in order to shutdown server from client application
parent c41ff154
......@@ -7,6 +7,7 @@ include( VistaCommon )
vista_use_package( VABase REQUIRED FIND_DEPENDENCIES )
vista_use_package( VACore REQUIRED FIND_DEPENDENCIES )
vista_use_package( VANet REQUIRED FIND_DEPENDENCIES )
vista_use_package( VistaTools REQUIRED FIND_DEPENDENCIES )
if( NOT ITA_VASERVER_INSTALL_WITH_DLLS )
set( ITA_VASERVER_INSTALL_WITH_DLLS ON CACHE BOOL "Install VAServer with depending DLLs (use this switch with care)" )
......
Copyright 2015-2018 Institute of Technical Acoustics (ITA), RWTH Aachen University
Copyright 2015-2020 Institute of Technical Acoustics (ITA), RWTH Aachen University
Licensed under the Apache License, Version 2.0 (the "License");
you may not use files of this project except in compliance with the License.
......
......@@ -4,7 +4,7 @@ VAServer is a lightweight command line C++ server application for real-time aura
### License
Copyright 2015-2018 Institute of Technical Acoustics (ITA), RWTH Aachen University
Copyright 2015-2020 Institute of Technical Acoustics (ITA), RWTH Aachen University
Licensed under the Apache License, Version 2.0 (the "License");
you may not use files of this project except in compliance with the License.
......
......@@ -4,7 +4,7 @@
* VVV VVV A Virtual Acoustics (VA) | http://www.virtualacoustics.org
* VVV VVV AAA Licensed under the Apache License, Version 2.0
* VVV VVV AAA
* VVV VVV AAA Copyright 2015-2019
* VVV VVV AAA Copyright 2015-2020
* VVVVVV AAA Institute of Technical Acoustics (ITA)
* VVVV AAA RWTH Aachen University
*
......@@ -32,6 +32,7 @@
#include <VACore.h>
#include <VANet.h>
#include <Windows.h>
#include <VistaBase/VistaTimeUtils.h>
using namespace std;
......@@ -90,12 +91,7 @@ public:
inline void HandleVAEvent( const CVAEvent* pEvent )
{
if( pEvent->iEventType == CVAEvent::SHOTDOWN_REQUEST )
{
raise( SIGINT );
//StopServer();
cout << "Closing server application after remote shutdown request" << endl;
exit( 0 );
}
};
};
......@@ -112,11 +108,11 @@ int main( int argc, char* argv[] )
signal( SIGBREAK, SignalHandler ); // closing window
signal( SIGTERM, SignalHandler );
signal( SIGINT, SignalHandler ); // CTRL+C etc.
// Arguments
bool bVersionInfoRequest = false;
bool bAllowClientShutdownMessage = true;
bool bRemoveControlMode = false;
std::string sServerAddress, sVACoreConfigPath;
if( argc == 1 )
......@@ -144,7 +140,7 @@ int main( int argc, char* argv[] )
if( argc >= 3 )
sVACoreConfigPath = argv[ 2 ];
if( argc >= 4 )
bAllowClientShutdownMessage = false;
bRemoveControlMode = true;
}
......@@ -200,7 +196,7 @@ int main( int argc, char* argv[] )
pCore->Initialize();
if( bAllowClientShutdownMessage )
if( bRemoveControlMode )
{
pServerCoreEventHandler = new CServerCoreEventHandler();
pCore->AttachEventHandler( pServerCoreEventHandler );
......@@ -228,121 +224,135 @@ int main( int argc, char* argv[] )
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 ] s List search paths" << endl <<
"[ VAServer ] q Quit" << endl << endl;
while( true )
if( bRemoveControlMode )
{
const int CTRL_D = 4;
int c = getch();
cout << "[ VAServer ] Enering remote control mode. Type CTRL+C to stop server manually or send shutdown message from client" << endl << endl;
if( c == CTRL_D || c == 'q' )
{
raise( SIGINT );
break;
}
int iMilliseconds = 250;
while( pCore != nullptr )
VistaTimeUtils::Sleep( iMilliseconds );
if( ( char ) c == 'm' )
raise( SIGINT );
}
else
{
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 ] s List search paths" << endl <<
"[ VAServer ] q Quit" << endl << endl;
while( true )
{
bool bMuted = pServer->GetCoreInstance()->GetOutputMuted();
cout << "[ VAServer ] " << ( !bMuted ? "Muting" : "Unmuting" ) << " global output" << endl;
pServer->GetCoreInstance()->SetOutputMuted( !bMuted );
}
const int CTRL_D = 4;
int c = getch();
if( ( char ) c == '0' )
{
cout << "[ VAServer ] Setting output gain to 0 dB" << endl;
pServer->GetCoreInstance()->SetOutputGain( 1.0 );
}
if( c == CTRL_D || c == 'q' )
{
raise( SIGINT );
break;
}
if( ( char ) c == '+' )
{
double dGain = pServer->GetCoreInstance()->GetOutputGain();
dGain *= 1.4125;
cout << "[ VAServer ] Setting output gain to " << ratio_to_db20_str( dGain ) << endl;
pServer->GetCoreInstance()->SetOutputGain( dGain );
}
if( ( char ) c == 'm' )
{
bool bMuted = pServer->GetCoreInstance()->GetOutputMuted();
cout << "[ VAServer ] " << ( !bMuted ? "Muting" : "Unmuting" ) << " global output" << endl;
pServer->GetCoreInstance()->SetOutputMuted( !bMuted );
}
if( ( char ) c == '-' )
{
double dGain = pServer->GetCoreInstance()->GetOutputGain();
dGain /= 1.4125;
cout << "[ VAServer ] Setting output gain to " << ratio_to_db20_str( dGain ) << endl;
pServer->GetCoreInstance()->SetOutputGain( dGain );
}
if( ( char ) c == '0' )
{
cout << "[ VAServer ] Setting output gain to 0 dB" << endl;
pServer->GetCoreInstance()->SetOutputGain( 1.0 );
}
if( ( char ) c == 'l' )
{
CVAStruct oArgs, oReturn, oNewArgs;
oArgs[ "getloglevel" ] = true;
oReturn = pServer->GetCoreInstance()->CallModule( "VACore", oArgs );
int iCurrentLogLevel = oReturn[ "loglevel" ];
int iNewLogLevel = int( iCurrentLogLevel + 1 ) % 6;
oNewArgs[ "setloglevel" ] = iNewLogLevel;
oReturn = pServer->GetCoreInstance()->CallModule( "VACore", oNewArgs );
cout << "[ VAServer ] Switched to log level: " << IVAInterface::GetLogLevelStr( iNewLogLevel ) << endl;
}
if( ( char ) c == '+' )
{
double dGain = pServer->GetCoreInstance()->GetOutputGain();
dGain *= 1.4125;
cout << "[ VAServer ] Setting output gain to " << ratio_to_db20_str( dGain ) << endl;
pServer->GetCoreInstance()->SetOutputGain( dGain );
}
if( ( char ) c == 's' )
{
CVAStruct oArgs, oReturn;
oArgs[ "getsearchpaths" ] = true;
oReturn = pServer->GetCoreInstance()->CallModule( "VACore", oArgs );
CVAStruct& oSearchPaths( oReturn[ "searchpaths" ] );
if( oSearchPaths.IsEmpty() )
cout << "[ VAServer ] No search paths added, yet" << endl;
else
if( ( char ) c == '-' )
{
double dGain = pServer->GetCoreInstance()->GetOutputGain();
dGain /= 1.4125;
cout << "[ VAServer ] Setting output gain to " << ratio_to_db20_str( dGain ) << endl;
pServer->GetCoreInstance()->SetOutputGain( dGain );
}
if( ( char ) c == 'l' )
{
CVAStruct oArgs, oReturn, oNewArgs;
oArgs[ "getloglevel" ] = true;
oReturn = pServer->GetCoreInstance()->CallModule( "VACore", oArgs );
int iCurrentLogLevel = oReturn[ "loglevel" ];
int iNewLogLevel = int( iCurrentLogLevel + 1 ) % 6;
oNewArgs[ "setloglevel" ] = iNewLogLevel;
oReturn = pServer->GetCoreInstance()->CallModule( "VACore", oNewArgs );
cout << "[ VAServer ] Switched to log level: " << IVAInterface::GetLogLevelStr( iNewLogLevel ) << endl;
}
if( ( char ) c == 's' )
{
cout << "[ VAServer ] Listing all search paths on server side:" << endl;
CVAStruct::const_iterator cit = oSearchPaths.Begin();
while( cit != oSearchPaths.End() )
CVAStruct oArgs, oReturn;
oArgs[ "getsearchpaths" ] = true;
oReturn = pServer->GetCoreInstance()->CallModule( "VACore", oArgs );
CVAStruct& oSearchPaths( oReturn[ "searchpaths" ] );
if( oSearchPaths.IsEmpty() )
cout << "[ VAServer ] No search paths added, yet" << endl;
else
{
CVAStructValue oValue( cit->second );
cit++;
if( oValue.IsString() )
cout << "[ VAServer ] + '" << std::string( oValue ) << "'" << endl;
cout << "[ VAServer ] Listing all search paths on server side:" << endl;
CVAStruct::const_iterator cit = oSearchPaths.Begin();
while( cit != oSearchPaths.End() )
{
CVAStructValue oValue( cit->second );
cit++;
if( oValue.IsString() )
cout << "[ VAServer ] + '" << std::string( oValue ) << "'" << endl;
}
}
}
}
if( ( char ) c == 'r' )
{
cout << "[ VAServer ] Resetting server manually" << endl;
pServer->GetCoreInstance()->Reset();
}
if( ( char ) c == 'c' )
{
if( !pServer->IsClientConnected() )
if( ( char ) c == 'r' )
{
cout << "[ VAServer ] Nothing yet, still waiting for connections" << endl;
cout << "[ VAServer ] Resetting server manually" << endl;
pServer->GetCoreInstance()->Reset();
}
else
if( ( char ) c == 'c' )
{
const int iNumClients = pServer->GetNumConnectedClients();
if( iNumClients == 1 )
cout << "[ VAServer ] One client connected" << endl;
if( !pServer->IsClientConnected() )
{
cout << "[ VAServer ] Nothing yet, still waiting for connections" << endl;
}
else
cout << "[ VAServer ] Counting " << iNumClients << " connections" << endl;
for( int i = 0; i < iNumClients; i++ )
{
cout << "[ VAServer ] + " << pServer->GetClientHostname( i ) << endl;
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;
pCore->Finalize();
delete pCore;
......
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