public class DeviceCenter
This class is the entry point to discover and use OCast devices.
In order to receive discovery events, you first need to register a device class by calling the
registerDevice(@NotNull Class deviceClass)
method. Then add a interface DeviceListener
with
addDeviceListener(@NotNull DeviceListener listener)
and start the discovery with resumeDiscovery()
.
interface DeviceListener
Modifier and Type | Class and Description |
---|---|
static class |
DeviceCenter.Companion
The companion object.
|
Modifier and Type | Field and Description |
---|---|
static DeviceCenter.Companion |
Companion
The companion object.
|
static long |
DEFAULT_DISCOVERY_INTERVAL
The default value for the discovery interval.
|
static long |
MINIMUM_DISCOVERY_INTERVAL
The minimum value for the discovery interval.
|
Constructor and Description |
---|
DeviceCenter()
Creates an instance of
class DeviceCenter . |
Modifier and Type | Method and Description |
---|---|
void |
addDeviceListener(DeviceListener listener)
Adds a listener for the device events.
|
void |
addEventListener(EventListener listener)
Adds a listener for the OCast protocol events.
|
CallbackWrapper |
getCallbackWrapper()
The callback wrapper.
|
java.util.List<org.ocast.sdk.core.Device> |
getDevices()
The list of detected OCast devices.
|
long |
getDiscoveryInterval()
The interval to refresh the devices, in milliseconds.
|
protected void |
onAddDevice(Device device)
This method is called when an OCast device has been created and before it is added to the list of detected devices.
|
protected void |
onRemoveDevice(Device device)
This method is called before an OCast device is removed from the list of detected devices.
|
boolean |
pauseDiscovery()
Pauses the discovery process.
|
void |
registerDevice(java.lang.Class<? extends org.ocast.sdk.core.Device> deviceClass)
Registers a class of devices to discover.
|
void |
removeDeviceListener(DeviceListener listener)
Removes a listener which has been previously added with the
addDeviceListener(@NotNull EventListener listener) method. |
void |
removeEventListener(EventListener listener)
Removes a listener which has been previously added with the
addEventListener(@NotNull EventListener listener) method. |
boolean |
resumeDiscovery()
Resumes the discovery process.
|
void |
setCallbackWrapper(CallbackWrapper value)
The callback wrapper.
|
void |
setDiscoveryInterval(long value)
The interval to refresh the devices, in milliseconds.
|
boolean |
stopDiscovery()
Stops the discovery process.
|
public static long DEFAULT_DISCOVERY_INTERVAL
The default value for the discovery interval.
public static long MINIMUM_DISCOVERY_INTERVAL
The minimum value for the discovery interval.
public static DeviceCenter.Companion Companion
The companion object.
public DeviceCenter()
Creates an instance of class DeviceCenter
.
class DeviceCenter
@NotNull public CallbackWrapper getCallbackWrapper()
The callback wrapper.
public void setCallbackWrapper(@NotNull CallbackWrapper value)
The callback wrapper.
@NotNull public java.util.List<org.ocast.sdk.core.Device> getDevices()
The list of detected OCast devices.
public long getDiscoveryInterval()
The interval to refresh the devices, in milliseconds.
Minimum value is 5000 milliseconds. Setting this property results in sending an SSDP M-SEARCH request immediately if discovery is on-going.
public void setDiscoveryInterval(long value)
The interval to refresh the devices, in milliseconds.
Minimum value is 5000 milliseconds. Setting this property results in sending an SSDP M-SEARCH request immediately if discovery is on-going.
protected void onAddDevice(@NotNull Device device)
This method is called when an OCast device has been created and before it is added to the list of detected devices.
Default implementation does nothing. This method is meant to be overridden by subclasses.
device
- The device to add.protected void onRemoveDevice(@NotNull Device device)
This method is called before an OCast device is removed from the list of detected devices.
Default implementation does nothing. This method is meant to be overridden by subclasses.
device
- The device to remove.public void registerDevice(@NotNull java.lang.Class<? extends org.ocast.sdk.core.Device> deviceClass)
Registers a class of devices to discover.
deviceClass
- The class of devices that will be searched during the discovery process.public void addEventListener(@NotNull EventListener listener)
Adds a listener for the OCast protocol events.
listener
- The listener to add.public void removeEventListener(@NotNull EventListener listener)
Removes a listener which has been previously added with the addEventListener(@NotNull EventListener listener)
method.
listener
- The listener to remove.public void addDeviceListener(@NotNull DeviceListener listener)
Adds a listener for the device events.
listener
- The listener to add.public void removeDeviceListener(@NotNull DeviceListener listener)
Removes a listener which has been previously added with the addDeviceListener(@NotNull EventListener listener)
method.
listener
- The listener to remove.public boolean resumeDiscovery()
Resumes the discovery process.
Newly initialized instances of class DeviceCenter
begin in a paused state, so you need to call this method to start the discovery.
true
if the discovery was successfully resumed, false
if there was an issue or if the discovery was already running.class DeviceCenter
public boolean stopDiscovery()
Stops the discovery process.
This clears the list of detected devices if the discovery was not in a paused state.
true
if the discovery was successfully stopped, false
if the discovery was already stopped.public boolean pauseDiscovery()
Pauses the discovery process.
This does not clear the list of detected devices.
true
if the discovery was successfully paused, false
if the discovery was not running.