Beispiel #1
0
BOOL CNetMgr::RemoveUpdateNotification(const GUID *pguidNode, const GUID *pguidClass, DWORD dwCmd)
{_STT();
	// Sanity checks
	if ( pguidNode == NULL || pguidClass == NULL )
		return FALSE;

	// Acquire lock
	CTlLocalLock ll( *this );
	if ( !ll.IsLocked() ) return FALSE;
	
	// Get a list of nodes for the specified class
	THList< DWORD, THList< GUID, CTimeout > > *pCmds = m_lstUpdates.get( *pguidClass );
	if ( pCmds == NULL ) return FALSE;

	// Get the list of nodes wanting updates on this command
	THList< GUID, CTimeout > *pNodes = pCmds->get( dwCmd );
	if ( pNodes == NULL ) return FALSE;

	// Erase this node
	pNodes->erase( *pguidNode );

	// Cleanup invalid nodes as we go...
	if ( !pNodes->Size() )
	{	pCmds->erase( dwCmd );
		if ( !pCmds->Size() ) m_lstUpdates.erase( *pguidClass );
	} // end if

	return TRUE;
}
Beispiel #2
0
BOOL CNetMgr::NotifyNetwork(const GUID *pguidClass, DWORD dwCmd)
{_STT();
	// Sanity checks
	if ( pguidClass == NULL ) return FALSE;

	// Acquire lock
	CTlLocalLock ll( *this );
	if ( !ll.IsLocked() ) return FALSE;

	//wjr 9/22/06...
	// "Special" case just between MainLoop & NetMgr.
	if( pguidClass
		&& IsEqualGUID( *pguidClass, NetCmd::IID )
		&& NetCmd::efDoCleanup == dwCmd )
	{	Cleanup();
		return TRUE;
	}
	//...wjr 9/22/06

	// Get a list of nodes for the specified class
	THList< DWORD, THList< GUID, CTimeout > > *pCmds = m_lstUpdates.get( *pguidClass );
	if ( pCmds == NULL )
		return FALSE;

	// Get the list of nodes wanting updates on this command
	THList< GUID, CTimeout > *pNodes = pCmds->get( dwCmd );
	if ( pNodes == NULL ) 
		return FALSE;

	BOOL bErased = FALSE;
	THList< GUID, CTimeout >::iterator it = NULL;
	while ( ( it = pNodes->next( it ) ) != NULL )

		// Attempt to send the message
		if ( !Msg( it->key(), pguidClass, dwCmd | CNetMsg::fUpdate ) )
		{	bErased = TRUE; it = pNodes->erase( it ); }

	// Cleanup invalid nodes as we go...
	if ( bErased && !pNodes->Size() )
	{	pCmds->erase( dwCmd );
		if ( !pCmds->Size() ) m_lstUpdates.erase( *pguidClass );
	} // end if

	return TRUE;
}