Backend/Networking/service.cpp
/*!
 * @brief Launch a new service
 * @details launch service wrapper
 * @param y points to memory location for serviceArgs data
 */
@brief Launch a new service
@details launch service wrapper
@param y points to memory location for serviceArgs data
@brief Launch a new service @details launch service wrapper @param y points to memory location for serviceArgs data
void* Service::launchService(void* y)
{
	newServiceArgs* x = (newServiceArgs*)y;
	if (!x->serverInstance)
		return NULL;
	GServer* serverInstance = x->serverInstance;
	x->command = x->sockData->getCommand();
	if(x->command.length() == 0)
		return NULL;
	Connection* cConnection = x->cConnection;
	if (!cConnection)
		return NULL;
	if (!cConnection->isFinished())
	{
		Service* cService = serverInstance->ServiceLookup(x->command);
		if (cService)
		{
			cService->StartService(x);
			shmea::ServiceData* retData = cService->execute(x->sockData);
			if(!retData)
			{
				serverInstance->socks->addResponseList(serverInstance, cConnection, retData);
			}
			cService->ExitService(x);
			delete cService;
		}
	}
	if (x)
		delete x;
	if (cConnection->isFinished())
		delete cConnection;
	return NULL;
}
void * Service :: launchService ( void * y ) { newServiceArgs * x = ( newServiceArgs * ) y ; if ( ! x -> serverInstance ) return NULL ; GServer * serverInstance = x -> serverInstance ; x -> command = x -> sockData -> getCommand ( ) ; if ( x -> command . length ( ) == 0 ) return NULL ; Connection * cConnection = x -> cConnection ; if ( ! cConnection ) return NULL ; if ( ! cConnection -> isFinished ( ) ) { Service * cService = serverInstance -> ServiceLookup ( x -> command ) ; if ( cService ) { cService -> StartService ( x ) ; shmea :: ServiceData * retData = cService -> execute ( x -> sockData ) ; if ( ! retData ) { serverInstance -> socks -> addResponseList ( serverInstance , cConnection , retData ) ; } cService -> ExitService ( x ) ; delete cService ; } } if ( x ) delete x ; if ( cConnection -> isFinished ( ) ) delete cConnection ; return NULL ; }
@brief Launch a new service
 @details launch service wrapper
 @param y points to memory location for serviceArgs data
@brief Launch a new service @details launch service wrapper @param y points to memory location for serviceArgs data
// Helper function for pthread_create // set the service args // Get the command in order to tell the service what to do //Uncomment this before commit!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // Connection is dead so ignore it // start the service // execute the service // exit the service // delete the Connection