private void expireDevices ( ) { long now = System . currentTimeMillis ( ) ; // Make a copy so we don't have to worry about concurrent modification. Map < InetAddress , DeviceAnnouncement > copy = new HashMap < InetAddress , DeviceAnnouncement > ( devices ) ; for ( Map . Entry < InetAddress , DeviceAnnouncement > entry : copy . entrySet ( ) ) { if ( now - entry . getValue ( ) . getTimestamp ( ) > MAXIMUM_AGE ) { devices . remove ( entry . getKey ( ) ) ; deliverLostAnnouncement ( entry . getValue ( ) ) ; } } if ( devices . isEmpty ( ) ) { firstDeviceTime . set ( 0 ) ; // We have lost contact with the Pro DJ Link network, so start over with next device. } }
Remove any device announcements that are so old that the device seems to have gone away .