WIP

parent 1a0435f3
......@@ -39,8 +39,9 @@ using namespace std;
IVAInterface* pCore = NULL;
IVANetServer* pServer = NULL;
IVAEventHandler* pServerCoreEventHandler = NULL;
void SignalHandler( int iSignum )
void StopServer()
{
try
{
......@@ -74,7 +75,21 @@ void SignalHandler( int iSignum )
cerr << "[ VAServer ][ Error ] An unknown error occured" << endl;
exit( 255 );
}
}
class CServerCoreEventHandler : public IVAEventHandler
{
public:
inline void HandleVAEvent( const CVAEvent* pEvent )
{
if( pEvent->iEventType == CVAEvent::DESTROY )
StopServer();
};
};
void SignalHandler( int iSignum )
{
StopServer();
exit( iSignum );
}
......@@ -89,6 +104,7 @@ int main( int argc, char* argv[] )
// Arguments
bool bVersionInfoRequest = false;
bool bAllowClientShutdownMessage = true;
std::string sServerAddress, sVACoreConfigPath;
if( argc == 1 )
......@@ -115,6 +131,8 @@ int main( int argc, char* argv[] )
sServerAddress = argv[ 1 ];
if( argc >= 3 )
sVACoreConfigPath = argv[ 2 ];
if( argc >= 4 )
bAllowClientShutdownMessage = false;
}
......@@ -170,6 +188,12 @@ int main( int argc, char* argv[] )
pCore->Initialize();
if( bAllowClientShutdownMessage )
{
pServerCoreEventHandler = new CServerCoreEventHandler();
pCore->AttachEventHandler( pServerCoreEventHandler );
}
// Server
pServer = IVANetServer::Create();
......@@ -306,11 +330,11 @@ int main( int argc, char* argv[] )
}
}
}
delete pServer;
pCore->Finalize();
delete pCore;
delete pServerCoreEventHandler;
}
catch( CVAException& e )
{
......
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