public class DeviceFinder extends LifecycleParticipant
| Modifier and Type | Field and Description |
|---|---|
static int |
ANNOUNCEMENT_PORT
The port to which devices broadcast announcement messages to report their presence on the network.
|
static int |
MAXIMUM_AGE
The number of milliseconds after which we will consider a device to have disappeared if
we have not received an announcement from it.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDeviceAnnouncementListener(DeviceAnnouncementListener listener)
Adds the specified device announcement listener to receive device announcements when DJ Link devices
are found on or leave the network.
|
void |
addIgnoredAddress(InetAddress address)
Start ignoring any device updates which are received from the specified address.
|
Set<DeviceAnnouncement> |
getCurrentDevices()
Get the set of DJ Link devices which currently can be seen on the network.
|
Set<DeviceAnnouncementListener> |
getDeviceAnnouncementListeners()
Get the set of device announcement listeners that are currently registered.
|
long |
getFirstDeviceTime()
Get the timestamp of when we saw the first announcement packet, to help the
VirtualCdj determine how
long it needs to watch for devices in order to avoid conflicts when self-assigning a device number. |
static DeviceFinder |
getInstance()
Get the singleton instance of this class.
|
DeviceAnnouncement |
getLatestAnnouncementFrom(int deviceNumber)
Find and return the device announcement that was most recently received from a device identifying itself
with the specified device number, if any.
|
long |
getStartTime()
Get the timestamp of when we started listening for device announcements.
|
boolean |
isRunning()
Check whether we are presently listening for device announcements.
|
void |
removeDeviceAnnouncementListener(DeviceAnnouncementListener listener)
Removes the specified device announcement listener so that it no longer receives device announcements when
DJ Link devices are found on or leave the network.
|
void |
removeIgnoredAddress(InetAddress address)
Stop ignoring device updates which are received from the specified address.
|
void |
start()
Start listening for device announcements and keeping track of the DJ Link devices visible on the network.
|
void |
stop()
Stop listening for device announcements.
|
String |
toString() |
addLifecycleListener, deliverLifecycleAnnouncement, ensureRunning, getLifecycleListeners, removeLifecycleListenerpublic static final int ANNOUNCEMENT_PORT
public static final int MAXIMUM_AGE
public boolean isRunning()
isRunning in class LifecycleParticipanttrue if our socket is open and monitoring for DJ Link device announcements on the networkpublic long getStartTime()
start() was called.IllegalStateException - if we are not listening for announcements.public long getFirstDeviceTime()
VirtualCdj determine how
long it needs to watch for devices in order to avoid conflicts when self-assigning a device number.IllegalStateException - if we are not listening for announcements, or if none have been seen.public void addIgnoredAddress(InetAddress address)
VirtualCdj, so that its updates do not cause it to appear as a device.address - the address from which any device updates should be ignored.public void removeIgnoredAddress(InetAddress address)
VirtualCdj, so that when it shuts down, its socket stops being treated specially.address - the address from which any device updates should be ignored.public void start()
throws SocketException
SocketException - if the socket to listen on port 50000 cannot be createdpublic void stop()
public Set<DeviceAnnouncement> getCurrentDevices()
VirtualCdj.getLatestStatusFor(DeviceUpdate) to find the current detailed status for that device,
as long as the Virtual CDJ is active.IllegalStateException - if the DeviceFinder is not activepublic DeviceAnnouncement getLatestAnnouncementFrom(int deviceNumber)
deviceNumber - the device number of interestIllegalStateException - if the DeviceFinder is not activepublic void addDeviceAnnouncementListener(DeviceAnnouncementListener listener)
listener is null or already present in the list
of registered listeners, no exception is thrown and no action is performed.
Device announcements are delivered to listeners on the Event Dispatch thread, so it is fine to interact with user interface objects in listener methods. Any code in the listener method must finish quickly, or unhandled events will back up and the user interface will be come unresponsive.
listener - the device announcement listener to addpublic void removeDeviceAnnouncementListener(DeviceAnnouncementListener listener)
listener is null or not present
in the list of registered listeners, no exception is thrown and no action is performed.listener - the device announcement listener to removepublic Set<DeviceAnnouncementListener> getDeviceAnnouncementListeners()
public static DeviceFinder getInstance()
Copyright © 2016–2018 Deep Symmetry, LLC. All rights reserved.