示例#1
0
/*
 * Map Service Id
 */
bool	CDbManager::mapService(TServiceId serviceId, TDatabaseId databaseId)
{
	if (serviceId.get() > 256 || _ServiceMap[serviceId.get()] != INVALID_DATABASE_ID)
	{
		nlwarning("CDbManager::mapService(): failed, serviceId '%hu' not valid or service already mapped", serviceId.get());
		return false;
	}

	_ServiceMap[serviceId.get()] = databaseId;

	CDatabase*	database = getDatabase(databaseId);
	if (database != NULL)
		database->mapToService(serviceId);

	return true;
}
示例#2
0
/*
 * Unmap Service Id
 */
bool	CDbManager::unmapService(NLNET::TServiceId serviceId)
{
	if (serviceId.get() > 256 || _ServiceMap[serviceId.get()] == INVALID_DATABASE_ID)
		return false;

	TDatabaseId	id = _ServiceMap[serviceId.get()];
	_ServiceMap[serviceId.get()] = INVALID_DATABASE_ID;

	CDatabase*	db = getDatabase(id);

	if (db != NULL)
	{
		db->mapToService(TServiceId(0xffff));
		db->releaseAll();
	}

	return true;
}