public class ControlPoint extends Object implements HTTPRequestListener
This class implements HTTPRequestListener to provide comprehensive UPnP control point functionality including device discovery, service enumeration, action invocation, and event subscription management. It serves as the primary interface for UPnP control applications.
Key features:
This class is used by UPnP control applications to discover, control, and monitor UPnP devices on the network, providing a complete framework for building UPnP control point functionality.
| Modifier and Type | Field and Description |
|---|---|
(package private) ListenerList | deviceChangeListenerList |
| Constructor and Description |
|---|
ControlPoint()Default constructor using default ports |
ControlPoint(int ssdpPort,
int httpPort)Create a control point with specified SSDP and HTTP ports. |
ControlPoint(int ssdpPort,
int httpPort,
InetAddress[] binds)Create a control point with specified ports and network bindings. |
| Modifier and Type | Method and Description |
|---|---|
void | addDeviceChangeListener(DeviceChangeListener listener) |
void | addEventListener(EventListener listener) |
void | addNotifyListener(NotifyListener listener)Add a notify listener. |
void | addSearchResponseListener(SearchResponseListener listener) |
void | finalize() |
Device | getDevice(String name)Get a device by its name or UDN. |
Disposer | getDeviceDisposer()Get the device disposer. |
DeviceList | getDeviceList()Get the list of discovered devices. |
String | getEventSubURI() |
long | getExpiredDeviceMonitoringInterval()Get the expired device monitoring interval. |
int | getHTTPPort()Get the HTTP port. |
protected HTTPServerList | getHTTPServerList()I2P was private |
RenewSubscriber | getRenewSubscriber() |
int | getSearchMx() |
protected SSDPNotifySocketList | getSSDPNotifySocketList()Get the SSDP notify socket list. |
int | getSSDPPort()Get the SSDP port. |
protected SSDPSearchResponseSocketList | getSSDPSearchResponseSocketList()Get the SSDP search response socket list. |
Service | getSubscriberService(String uuid) |
Object | getUserData() |
boolean | hasDevice(String name)Check if a device with the given name or UDN exists. |
void | httpRequestRecieved(HTTPRequest httpReq)Called when an HTTP request is received. |
boolean | isNMPRMode()Check if NMPR mode is enabled. |
boolean | isSubscribed(Service service) |
void | lock()Lock the mutex |
void | notifyReceived(SSDPPacket packet) |
void | performAddDeviceListener(Device dev) |
void | performEventListener(String uuid,
long seq,
String name,
String value) |
void | performNotifyListener(SSDPPacket ssdpPacket)Notify all registered notify listeners of a received SSDP packet. |
void | performRemoveDeviceListener(Device dev) |
void | performSearchResponseListener(SSDPPacket ssdpPacket) |
void | print() |
protected void | removeDevice(Device dev)Remove a device from the device list. |
protected void | removeDevice(String name)Remove a device by its name or UDN. |
void | removeDeviceChangeListener(DeviceChangeListener listener) |
void | removeEventListener(EventListener listener) |
void | removeExpiredDevices()Remove all expired devices |
void | removeNotifyListener(NotifyListener listener)Remove a notify listener. |
void | removeSearchResponseListener(SearchResponseListener listener) |
void | renewSubscriberService()Renew all subscriber services with infinite timeout |
void | renewSubscriberService(Device dev,
long timeout) |
void | renewSubscriberService(long timeout) |
void | search()Search for all root devices |
void | search(String target) |
void | search(String target,
int mx) |
void | searchResponseReceived(SSDPPacket packet) |
void | setDeviceDisposer(Disposer disposer)Set the device disposer. |
void | setEventSubURI(String url) |
void | setExpiredDeviceMonitoringInterval(long interval)Set the expired device monitoring interval. |
void | setHTTPPort(int port)Set the HTTP port. |
void | setNMPRMode(boolean flag)Set the NMPR mode flag. |
void | setRenewSubscriber(RenewSubscriber sub) |
void | setSearchMx(int mx) |
void | setSSDPPort(int port)Set the SSDP port. |
void | setUserData(Object data) |
boolean | start()Start with default search target |
boolean | start(String target) |
boolean | start(String target,
int mx) |
boolean | stop() |
boolean | subscribe(Service service) |
boolean | subscribe(Service service,
long timeout) |
boolean | subscribe(Service service,
String uuid) |
boolean | subscribe(Service service,
String uuid,
long timeout) |
void | unlock()Unlock the mutex |
void | unsubscribe()Unsubscribe from all services |
void | unsubscribe(Device device) |
boolean | unsubscribe(Service service) |
ListenerList deviceChangeListenerList
public ControlPoint()
public ControlPoint(int ssdpPort,
int httpPort)ssdpPort - the SSDP porthttpPort - the HTTP portpublic ControlPoint(int ssdpPort,
int httpPort,
InetAddress[] binds)ssdpPort - the SSDP porthttpPort - the HTTP portbinds - the network interfaces to bind to, or null for allpublic void addDeviceChangeListener(DeviceChangeListener listener)
listener - the device change listener to addpublic void addEventListener(EventListener listener)
listener - the event listener to addpublic void addNotifyListener(NotifyListener listener)
public void addSearchResponseListener(SearchResponseListener listener)
listener - the search response listener to addpublic Device getDevice(String name)
name - the device name or UDNpublic Disposer getDeviceDisposer()
public DeviceList getDeviceList()
public String getEventSubURI()
public long getExpiredDeviceMonitoringInterval()
public int getHTTPPort()
protected HTTPServerList getHTTPServerList()
public RenewSubscriber getRenewSubscriber()
public int getSearchMx()
protected SSDPNotifySocketList getSSDPNotifySocketList()
public int getSSDPPort()
protected SSDPSearchResponseSocketList getSSDPSearchResponseSocketList()
public Service getSubscriberService(String uuid)
uuid - the subscription IDpublic Object getUserData()
public boolean hasDevice(String name)
name - the device name or UDNpublic void httpRequestRecieved(HTTPRequest httpReq)
HTTPRequestListenerhttpRequestRecieved in interface HTTPRequestListenerhttpReq - the received HTTP requestpublic boolean isNMPRMode()
public boolean isSubscribed(Service service)
service - the servicepublic void lock()
public void notifyReceived(SSDPPacket packet)
packet - the received SSDP packetpublic void performAddDeviceListener(Device dev)
dev - the device that was addedpublic void performEventListener(String uuid, long seq, String name, String value)
uuid - the subscription IDseq - the sequence numbername - the property namevalue - the property valuepublic void performNotifyListener(SSDPPacket ssdpPacket)
public void performRemoveDeviceListener(Device dev)
dev - the device that was removedpublic void performSearchResponseListener(SSDPPacket ssdpPacket)
ssdpPacket - the received SSDP packetpublic void print()
protected void removeDevice(Device dev)
protected void removeDevice(String name)
public void removeDeviceChangeListener(DeviceChangeListener listener)
listener - the device change listener to removepublic void removeEventListener(EventListener listener)
listener - the event listener to removepublic void removeExpiredDevices()
public void removeNotifyListener(NotifyListener listener)
public void removeSearchResponseListener(SearchResponseListener listener)
listener - the search response listener to removepublic void renewSubscriberService()
public void renewSubscriberService(Device dev, long timeout)
dev - the device whose subscriptions to renewtimeout - the subscription timeoutpublic void renewSubscriberService(long timeout)
timeout - the subscription timeoutpublic void search()
public void search(String target)
target - the search targetpublic void search(String target, int mx)
target - the search targetmx - the maximum wait timepublic void searchResponseReceived(SSDPPacket packet)
packet - the search response packetpublic void setDeviceDisposer(Disposer disposer)
public void setEventSubURI(String url)
url - the event subscription URIpublic void setExpiredDeviceMonitoringInterval(long interval)
public void setHTTPPort(int port)
public void setNMPRMode(boolean flag)
public void setRenewSubscriber(RenewSubscriber sub)
sub - the renew subscriberpublic void setSearchMx(int mx)
mx - the search MX valuepublic void setSSDPPort(int port)
public void setUserData(Object data)
data - user-defined datapublic boolean start()
public boolean start(String target)
target - the search targetpublic boolean start(String target, int mx)
target - the search targetmx - the maximum wait time for responsespublic boolean stop()
public boolean subscribe(Service service)
service - the service to subscribe topublic boolean subscribe(Service service, long timeout)
service - the service to subscribe totimeout - the subscription timeoutpublic boolean subscribe(Service service, String uuid)
service - the serviceuuid - the subscription IDpublic boolean subscribe(Service service, String uuid, long timeout)
service - the serviceuuid - the subscription IDtimeout - the timeoutpublic void unlock()
public void unsubscribe()
public void unsubscribe(Device device)
device - the device to unsubscribepublic boolean unsubscribe(Service service)
service - the service