WIP

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