net.sbbi.upnp
Class DiscoveryAdvertisement

java.lang.Object
  extended bynet.sbbi.upnp.DiscoveryAdvertisement
All Implemented Interfaces:
java.lang.Runnable

public class DiscoveryAdvertisement
extends java.lang.Object
implements java.lang.Runnable

SSDP messages listener Thread, notify registered objects implementing the interface DiscoveryEventHandler
when a device joins the networks or leaves it.
The listener thread is set to only accept matching device description and broadcast message sender IP to avoid a security flaw with the protocol. If you are not happy with such behaviour you can set the net.sbbi.upnp.ddos.matchip system property to false to avoid this check.

Version:
1.0
Author:
SuperBonBon

Field Summary
static int EVENT_SSDP_ALIVE
           
static int EVENT_SSDP_BYE_BYE
           
 
Method Summary
static DiscoveryAdvertisement getInstance()
           
 void registerEvent(int notificationEvent, java.lang.String nt, DiscoveryEventHandler eventHandler)
          Registers an event category sent by UPNP devices
 void run()
           
 void setDaemon(boolean daemon)
           
 void unRegisterEvent(int notificationEvent, java.lang.String nt, DiscoveryEventHandler eventHandler)
          Unregisters an event category sent by UPNP devices
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EVENT_SSDP_ALIVE

public static final int EVENT_SSDP_ALIVE
See Also:
Constant Field Values

EVENT_SSDP_BYE_BYE

public static final int EVENT_SSDP_BYE_BYE
See Also:
Constant Field Values
Method Detail

getInstance

public static final DiscoveryAdvertisement getInstance()

setDaemon

public void setDaemon(boolean daemon)

registerEvent

public void registerEvent(int notificationEvent,
                          java.lang.String nt,
                          DiscoveryEventHandler eventHandler)
                   throws java.io.IOException
Registers an event category sent by UPNP devices

Parameters:
notificationEvent - the event type, either DiscoveryAdvertisement.EVENT_SSDP_ALIVE or DiscoveryAdvertisement.EVENT_SSDP_BYE_BYE
nt - the type of device advertisement, upnp:rootdevice will return you all advertisement in relation with nt upnp:rootdevice a null value specify that all nt type are wanted
eventHandler - the events handler, this objet will receive notifications..
Throws:
java.io.IOException - if an error ocurs when the SSDP events listeners threads starts

unRegisterEvent

public void unRegisterEvent(int notificationEvent,
                            java.lang.String nt,
                            DiscoveryEventHandler eventHandler)
Unregisters an event category sent by UPNP devices

Parameters:
notificationEvent - the event type, either DiscoveryAdvertisement.EVENT_SSDP_ALIVE or DiscoveryAdvertisement.EVENT_SSDP_BYE_BYE
nt - the type of device advertisement, upnp:rootdevice will unregister all advertisement in relation with nt upnp:rootdevice a null value specify that all nt type are unregistered
eventHandler - the events handler that needs to be unregistred.

run

public void run()
Specified by:
run in interface java.lang.Runnable


Copyright © 2005 SuperBonBon Industries. All Rights Reserved.