diff --git a/xwords4/relay/devmgr.cpp b/xwords4/relay/devmgr.cpp index 1479dee65..88773f201 100644 --- a/xwords4/relay/devmgr.cpp +++ b/xwords4/relay/devmgr.cpp @@ -102,16 +102,26 @@ DevMgr::get( DevIDRelay devid ) return result; } -bool -DevMgr::forgetDevice( DevIDRelay devid ) +int +DevMgr::forgetDevices( vector& devids ) { + int count = 0; MutexLock ml( &m_mapLock ); - map::iterator iter = m_devAddrMap.find( devid ); - bool found = m_devAddrMap.end() != iter; - if ( found ) { - m_devAddrMap.erase( iter ); + if ( 0 == devids.size() ) { + count = m_devAddrMap.size(); + m_devAddrMap.clear(); + } else { + vector::const_iterator devidIter; + for ( devidIter = devids.begin(); devids.end() != devidIter; ++devidIter ) { + map::iterator iter = + m_devAddrMap.find( *devidIter ); + if ( m_devAddrMap.end() != iter ) { + ++count; + m_devAddrMap.erase( iter ); + } + } } - return found; + return count; } void diff --git a/xwords4/relay/devmgr.h b/xwords4/relay/devmgr.h index 140395b0c..67bd0c4ee 100644 --- a/xwords4/relay/devmgr.h +++ b/xwords4/relay/devmgr.h @@ -36,7 +36,7 @@ class DevMgr { /* Called from ctrl port */ void printDevices( string& str, vector devids /* empty means all */ ); - bool forgetDevice( DevIDRelay devid ); + int forgetDevices( vector& devids ); void getKnownDevices( vector& devids ); private: